8/09/2012

JAX-WS client throwing java.lang.NoClassDefFoundError: com/sun/xml/ws/spi/ProviderImpl

I had generated and tested my JAX-WS client using Weblogic 10 libraries on Java 6 update 16.
Tested this on JRE Update 25, no additional jars were required. Not even wseeclient or wlclient. Apparently the default JAX-WS runtime was doing its job.

However, when I tried to run the same application on JDK 6 update 10, I got the following:


Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/xml/ws/spi/ProviderImpl
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:630)
....

Apparently com/sun/xml/ws/spi/ProviderImpl was nowhere to be found. On some forums I found that this could be resolved by using "endorsed" option. For some reason that didn't work for me  and I kept getting the same error.

I tried to force-load the weblogic provider, but in vain. Same error. Needless to say this was very annoying and I was almost on the verge of switching to Axis.


So, as a last resort, I tried to do things the old fashioned way. Downloaded the JAX-WS RI (http://jax-ws.java.net/2.1.3/) .


Added libraries to classpath as given in its installation guide. No endorsements, just plain old classpath.

And voila. It worked like charm.



So I'm thinking if Java is turning into a Jar hell (as opposed to the DLL hell). Java definitely need a better way to manage library dependency something like Maven. Right now, if it's not for Google, some problems will never get fixed!