Java Wrapper cannot find main class

Java Service Wrapper are tools that I need to run as a Windows service, but have encountered the java.lang.ClassNotFoundException problem

My standard command line is: java -jar software.jar

I have a wrapper.conf update to run software.jar located in D: \, and an error occurred, my changes made:

 # Java Classpath (include wrapper.jar) Add class path elements as # needed starting from 1 wrapper.java.classpath.1=../software.jar wrapper.java.classpath.2=../lib/wrapper.jar 

and what should I put for this parameter? If I comment, it will use Main class

 wrapper.java.mainclass=software 

As I declare "software" the main class, I got an error:

 wrapper | Launching a JVM... jvm 1 | java.lang.NoClassDefFoundError: org/xsocket/connection/IHandler jvm 1 | Caused by: java.lang.ClassNotFoundException: org.xsocket.connection.I Handler jvm 1 | at java.net.URLClassLoader$1.run(URLClassLoader.java:202) jvm 1 | at java.security.AccessController.doPrivileged(Native Method) jvm 1 | at java.net.URLClassLoader.findClass(URLClassLoader.java:190) jvm 1 | at java.lang.ClassLoader.loadClass(ClassLoader.java:307) jvm 1 | at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) jvm 1 | at java.lang.ClassLoader.loadClass(ClassLoader.java:248) jvm 1 | Could not find the main class: xSocketServer. Program will exit. wrapper | JVM exited while loading the application. jvm 1 | Exception in thread "main" wrapper | CTRL-C trapped. Shutting down. wrapper | <-- Wrapper Stopped 

My software contains:

 META-INF org -- Eclipse setting software.class xsoftwareHandler.class xSocket.jar 
+4
source share
3 answers

I suggest storing all the libraries in the lib/ directory and then adding the following information to your wrapper.conf file:

 wrapper.java.classpath.1=../lib/*.jar 

Thus, the Java Service Wrapper load the entire *.jar file located in the ../lib/ directory in the classpath, and you should not get this error again.

Of course, you can also define each JAR separately if you want:

 wrapper.java.classpath.1=../lib/wrapper.jar wrapper.java.classpath.2=../software.jar wrapper.java.classpath.3=../lib/xSocket.jar ... 
+2
source

How do you use an executable jar to run the application normally. You might want to try the WrapperJarApp helper class. It is designed to integrate with executable banks, without requiring you to look into the manifest file for the main class name. Take a look at this page for more information: http://wrapper.tanukisoftware.com/doc/english/integrate.html#method4

It is available from version 3.3.3.

Cheers, Leif

+2
source

The actual error does not seem to be in the main class. It seems that "xSocket.jar" is not in the classpath.

0
source

All Articles