Page 1 of 3 123 LastLast
Results 1 to 20 of 44
  1. #1
    Starvation is offline Member
    Join Date
    Jun 2010
    Posts
    23
    Rep Power
    0

    Default System Properties

    Hi there

    I am working with a Web Service (using Axis2) and I created a java client (called Test2)

    But I've got a problem when I run the client class

    to get it going I use the command

    "Java-Djava.ext.dirs = c: / temp / lib Test2"

    from what I understand with the command -D I set a system property... and in this case I am saying that there are external libraries that must go get in the folder "c: / temp / lib"

    with this command, before returning the desired output of the WS, console comes out the message
    Java Code:
    [INFO] Deploying module: MetadataExchange-1.5.1 - file: / C: / Temp/lib/mex-1.5.1. jar
    and thanks to the command
    Java Code:
     
    System.getProperties (). List (System.out);
    (I print to video all "system properties" one by one)

    I can see that the "java.ext.dirs" is given the path "c: / temp / lib"


    What I would do would be to simply run the client Test2 without setting the properties by the console, if this is necessary i prefer setting properties in the code, and I've tried it...


    I imported "java.util.Properties" and I used the command
    Java Code:
    System.setProperty ("java.ext.dirs", "c: / temp / lib");
    Now running the file with "java Test2" I see the "java.ext.dirs" is given the correct path I wanted to give it but I did not print the console line
    Java Code:
    [INFO] Deploying module: MetadataExchange-1.5.1 - file: / C: / Temp/lib/mex-1.5.1.jar
    and the program ends with an error
    Java Code:
     
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/axis2/client/Stub 
            java.lang.ClassLoader.defineClass1 at (Native Method) 
            java.lang.ClassLoader.defineClassCond at (Unknown Source) 
            at java.lang.ClassLoader.defineClass (Unknown Source) 
            at java.security.SecureClassLoader.defineClass (Unknown Source) 
            at java.net.URLClassLoader.defineClass (Unknown Source) 
            at java.net.URLClassLoader.access $ 000 (Unknown Source) 
            at java.net.URLClassLoader $ 1.run (Unknown Source) 
            at java.security.AccessController.doPrivileged (Native Method) 
            at java.net.URLClassLoader.findClass (Unknown Source) 
            at java.lang.ClassLoader.loadClass (Unknown Source) 
            at sun.misc.Launcher $ AppClassLoader.loadClass (Unknown Source) 
            at java.lang.ClassLoader.loadClass (Unknown Source) 
            at Test2.client (Test2.java: 26) 
            at Test2.main (Test2.java: 64) 
    Caused by: java.lang.ClassNotFoundException: org.apache.axis2.client.Stub 
            at java.net.URLClassLoader $ 1.run (Unknown Source) 
            at java.security.AccessController.doPrivileged (Native Method) 
            at java.net.URLClassLoader.findClass (Unknown Source) 
            at java.lang.ClassLoader.loadClass (Unknown Source) 
            at sun.misc.Launcher $ AppClassLoader.loadClass (Unknown Source) 
            at java.lang.ClassLoader.loadClass (Unknown Source) 
            ... 14 more
    someone from the forum has some ideas that I could be closer to solving the problem?

    Thanks for your patience even to have read :)
    Bye

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    NoClassDefFoundError: org/apache/axis2/client/Stub
    The JVM can't find the class referred to in the error message.
    Do you know where that class file is located? Can you make it available to the JVM.

  3. #3
    Starvation is offline Member
    Join Date
    Jun 2010
    Posts
    23
    Rep Power
    0

    Default

    Unfortunately I don't know where is located the Stub class...and even the path where it search that class...

    I can't realize why if I set the property in the console
    Java Code:
    java -Djava.ext.dirs=c:/temp/lib Test2
    it work....but if I set it in the code it don't work

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default

    Have you looked in that directory?
    That command says, as you say, "here is a location to find some more extensions", or jars essentially.
    The JVM needs to know (unless you are planning on loading classes by hand) where to find all the stuff the code you are running depends on, and it needs to know this before it starts up...so you can't simply add what is (sort of) another bit of the classpath during execution.

  5. #5
    Starvation is offline Member
    Join Date
    Jun 2010
    Posts
    23
    Rep Power
    0

    Default

    Understood....so is there a way to set definitively " java.ext.dirs " ?

    The problem is that I can't put that jar in JAVA_HOME/jre/lib/ext because mex-1.5.1 is an Axis module and should stay under Axis lib folder....

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    No, your problem is that the JVM reads that system property on startup, as that information is needed immediately, before it ever gets to your class.

  7. #7
    Starvation is offline Member
    Join Date
    Jun 2010
    Posts
    23
    Rep Power
    0

    Default

    ok, indeed i was wondering if is possible to set (and save) that property

    on startup, JVM reads that system property (that is located somewhere)...if I change that property definitively i should have resolved my problem
    or maybe not?

  8. #8
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Write a small batch script for starting your program. Or, even better, create aconfiguration file and a start script and have the start script read the startup options out the config file.

  9. #9
    Starvation is offline Member
    Join Date
    Jun 2010
    Posts
    23
    Rep Power
    0

    Default

    This client class will be called by an applet, that's why I need that it works
    properly without setting that property through the console

    It's why I don't know if a batch or a script will be able to solve this issue

  10. #10
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Well, the "client" class cannot be started as a separate JVM by an Applet, so what you are looking for is how to set Applet plug-in JVM parameters. Google Java control Panel. I am, however, fairly certain that you can't set the ext dirs for the plugin, and that you definately cannot have an Applet set it seperately to inlcude a jar from it's site. You can't then, even use the workaround of creating ClassLoader and setting that ClassLoader as the context classloader as you can't do that in Applets.

    Besides, I am quite sure that this does not need to be defined using extdirs. Include the jars on your classpath as normal (for Applets that is using JNLP or the archive tag).

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default

    That's what I was wondering because I don't think I've ever used ext.dirs, and I've definitely used Axis.

  12. #12
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by Tolls View Post
    That's what I was wondering because I don't think I've ever used ext.dirs, and I've definitely used Axis.
    I am quite sure he is looking for a shortcut for including all of the lib jars.

    Of course, as of Java 6, that's easy, since you can use the "*". I.E. -cp=/axis/lib/*

    ;-)

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default

    Don't IDEs automate all this sort of stuff for you?
    I don't do Applets, so I'm not sure, but I'd have thought they would...they automate everything else.

  14. #14
    Starvation is offline Member
    Join Date
    Jun 2010
    Posts
    23
    Rep Power
    0

    Default

    I was thinking the same about IDEs....I've worked with Notepad until now...
    I will retry with Eclipse Galileo

  15. #15
    Starvation is offline Member
    Join Date
    Jun 2010
    Posts
    23
    Rep Power
    0

    Default

    Solved with eclipse, now if I run that class from the console it works....

    BUT

    if I call this class from an applet it gives an error:

    Java Code:
    org.apache.axis2.AxisFault: Connection refused: connect
    	at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
    	at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
    	at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
    	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:364)
    	at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:208)
    	at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
    	at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:401)
    	at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
    	at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
    	at queryws.QueryWSStub.interroga(QueryWSStub.java:186)
    	at queryws.QueryWSClient.querydb(QueryWSClient.java:23)
    	at queryws.Applet.paint(Applet.java:36)
    	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
    	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
    	at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source)
    	at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.net.ConnectException: Connection refused: connect
    	at java.net.PlainSocketImpl.socketConnect(Native Method)
    	at java.net.PlainSocketImpl.doConnect(Unknown Source)
    	at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    	at java.net.PlainSocketImpl.connect(Unknown Source)
    	at java.net.SocksSocketImpl.connect(Unknown Source)
    	at java.net.Socket.connect(Unknown Source)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
    	at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:125)
    	at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
    	at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
    	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
    	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    	at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:542)
    	at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:189)
    The question is....
    I need a WS with a method where a user have to give 2 parameters (an IP and a
    query)...it returns a String with the result of the query (and I've done this)

    How can I make this possible from a web page? (maybe with an applet?)
    Last edited by Starvation; 06-18-2010 at 02:42 PM.

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Applets can only communicate with the site they are loaded from. I don't see any Permission problem reported in the error message.

    So why was the connection refused?

    Can you write a small applet program to demo the problem that we could test with?

  17. #17
    Starvation is offline Member
    Join Date
    Jun 2010
    Posts
    23
    Rep Power
    0

    Default

    Applet.java:
    Java Code:
    import java.awt.*;
    
    public class Applet extends javax.swing.JApplet {
    
    	private String ip;
    	private String query;
    	
    	public void init(){
    	}
    
    
    	public void paint(Graphics schermo){
    
    		Graphics2D schermo2D = (Graphics2D)schermo;
    		Font tipo = new Font("Monospaced", Font.BOLD, 15);
    		schermo2D.setFont(tipo);
    
    		ip = "127.0.0.1";
    		query = "SELECT * FROM ruolo WHERE ruolo = 'manager'";
    		
                    schermo2D.drawString( "ip : " + ip, 5, 15 );
    		schermo2D.drawString( "query : " + query, 5, 45 );
    		
    		final String asd = QueryWSClient.querydb(ip, query);
    		    
    		schermo2D.drawString( "query result: " + asd, 5, 75 );
            
    	   }	
    
    
    	}





    QueryWSClient.java:
    Java Code:
    public class QueryWSClient 
    {
    	
    public static String querydb(String ip, String query)
    {
    	
    	QueryWSStub stub;
    	QueryWSStub.InterrogaResponse res = new QueryWSStub.InterrogaResponse();
    	try 
        {
        
            stub = new QueryWSStub("http://localhost:8080/axis2/services/InterrogaDB");
            QueryWSStub.Interroga queryDb = new QueryWSStub.Interroga();
            queryDb.setIp(ip);
            queryDb.setQuery(query);
            res = stub.interroga(queryDb);  
            
            
        }
        catch (Exception e) 
        {
           e.printStackTrace();
        }	
    
        return res.get_return();
    }
    }

    If I write a main method in QueryWSClient like
    Java Code:
    public static void main(String[] args) 
    	{
    
    		System.out.println( querydb("127.0.0.1","SELECT * FROM ruolo") ) ;
    
    	}
    it works properly, but if I call the same method from the applet it doesn't work...
    the problem is at the line
    Java Code:
        res = stub.interroga(queryDb);
    "interroga" is the method of the WS which will return a string with the query result of a certain DB that is located at that IP

  18. #18
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Is your code executeable on my computer? If not, I can't test it.

  19. #19
    Starvation is offline Member
    Join Date
    Jun 2010
    Posts
    23
    Rep Power
    0

    Default

    Unfortunately to run this code you need 3 more classes, Axis2 installed and the Web Service deployed on a pc that you can reach :(

    and I can't ask you to do all this work....thank you anyway

  20. #20
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Are all those things necessary to demo the code?
    Or is the problem related to your environment and configuration?

    An applet loaded from a site should be able to communicate with that site.
    How does your applet communicate with its site? Is it java code or some other?

Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 3
    Last Post: 02-07-2010, 08:34 PM
  2. Getting .mp3 properties
    By Leprechaun in forum New To Java
    Replies: 1
    Last Post: 02-06-2008, 05:55 AM
  3. List of System properties
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-29-2007, 04:56 PM
  4. Getting System Properties
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-19-2007, 05:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •