简体   繁体   中英

NoClassDefFoundError executing jar using jaxrpc

I have developed a Webservice client application using jaxrpc. Within eclipse the application runs fine, however after I have exported the jar file, I get the following runtime error

D:\>java -jar Myclient2.jar
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/rpc/Service
Exception
        at Mynet.MyScheduler.<init>(MyScheduler.java:47)
        at Mynet.MyScheduler.<init>(MyScheduler.java:36)
        at Mynet.MyNetMain.main(MyNetMain.java:11)
Caused by: java.lang.ClassNotFoundException: javax.xml.rpc.ServiceException
        at java.net.URLClassLoader$1.run(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)
        ... 3 more

I have tried to set the CLASSPATH variable but no changes.

set CLASSPATH=%CLASSPATH%;D:\eclipse\plugins\javax.xml.rpc_1.1.0.v201209140446\lib\jaxrpc.jar
set CLASSPATH=%CLASSPATH%;D:\eclipse\plugins\org.apache.axis_1.4.0.v201005080400\lib\axis.jar

echo %CLASSPATH%
java -jar Myclient2.jar

I am rather new to java so definitely a newbie question KR

You should consider migrating your web service to JAX-WS. JAX-RPC is an older java web service technology that is unlikely to be maintained much moving forward.

But the single biggest benefit you will experience is that all of the JAX-WS runtime and tooling has been part of the Java JDK since Java 6. This means that you can build web services with no runtime library dependencies.

Anytime that you get "java.lang.NoClassDefFoundError"; it is very probable that you are missing a jar file. you should search for the jar file containing "javax/xml/rpc" and then add it to your classpath or as a dependency to your maven project. Here you should find them:

http://search.maven.org/

http://mvnrepository.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM