Results 1 to 20 of 44
Thread: System Properties
- 06-16-2010, 04:00 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 23
- Rep Power
- 0
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
and thanks to the commandJava Code:[INFO] Deploying module: MetadataExchange-1.5.1 - file: / C: / Temp/lib/mex-1.5.1. jar
(I print to video all "system properties" one by one)Java Code:System.getProperties (). List (System.out);
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
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 lineJava Code:System.setProperty ("java.ext.dirs", "c: / temp / lib");
and the program ends with an errorJava Code:[INFO] Deploying module: MetadataExchange-1.5.1 - file: / C: / Temp/lib/mex-1.5.1.jar
someone from the forum has some ideas that I could be closer to solving the problem?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
Thanks for your patience even to have read :)
Bye
- 06-16-2010, 04:37 PM #2
The JVM can't find the class referred to in the error message.NoClassDefFoundError: org/apache/axis2/client/Stub
Do you know where that class file is located? Can you make it available to the JVM.
- 06-16-2010, 06:23 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 23
- Rep Power
- 0
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
it work....but if I set it in the code it don't workJava Code:java -Djava.ext.dirs=c:/temp/lib Test2
- 06-17-2010, 09:02 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,471
- Rep Power
- 16
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.
- 06-17-2010, 10:50 AM #5
Member
- Join Date
- Jun 2010
- Posts
- 23
- Rep Power
- 0
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....
- 06-17-2010, 11:07 AM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
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.
- 06-17-2010, 11:24 AM #7
Member
- Join Date
- Jun 2010
- Posts
- 23
- Rep Power
- 0
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?
- 06-17-2010, 11:35 AM #8
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
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.
- 06-17-2010, 11:48 AM #9
Member
- Join Date
- Jun 2010
- Posts
- 23
- Rep Power
- 0
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
- 06-17-2010, 12:36 PM #10
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
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).
- 06-17-2010, 12:51 PM #11
Moderator
- Join Date
- Apr 2009
- Posts
- 10,471
- Rep Power
- 16
That's what I was wondering because I don't think I've ever used ext.dirs, and I've definitely used Axis.
- 06-17-2010, 12:53 PM #12
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
- 06-17-2010, 01:20 PM #13
Moderator
- Join Date
- Apr 2009
- Posts
- 10,471
- Rep Power
- 16
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.
- 06-17-2010, 02:23 PM #14
Member
- Join Date
- Jun 2010
- Posts
- 23
- Rep Power
- 0
I was thinking the same about IDEs....I've worked with Notepad until now...
I will retry with Eclipse Galileo
- 06-18-2010, 02:40 PM #15
Member
- Join Date
- Jun 2010
- Posts
- 23
- Rep Power
- 0
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:
The question is....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)
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.
- 06-18-2010, 02:54 PM #16
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?
- 06-18-2010, 05:29 PM #17
Member
- Join Date
- Jun 2010
- Posts
- 23
- Rep Power
- 0
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
it works properly, but if I call the same method from the applet it doesn't work...Java Code:public static void main(String[] args) { System.out.println( querydb("127.0.0.1","SELECT * FROM ruolo") ) ; }
the problem is at the line
"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 IPJava Code:res = stub.interroga(queryDb);
- 06-18-2010, 05:48 PM #18
Is your code executeable on my computer? If not, I can't test it.
- 06-18-2010, 05:59 PM #19
Member
- Join Date
- Jun 2010
- Posts
- 23
- Rep Power
- 0
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
- 06-18-2010, 06:11 PM #20
Similar Threads
-
Convert Cartesian coordinate system into java coordinate system?
By 123 in forum Java 2DReplies: 3Last Post: 02-07-2010, 08:34 PM -
Getting .mp3 properties
By Leprechaun in forum New To JavaReplies: 1Last Post: 02-06-2008, 05:55 AM -
List of System properties
By Java Tip in forum Java TipReplies: 0Last Post: 12-29-2007, 04:56 PM -
Getting System Properties
By Java Tip in forum Java TipReplies: 0Last Post: 11-19-2007, 05:00 PM


LinkBack URL
About LinkBacks


Bookmarks