简体   繁体   中英

Compile-time VS run-time

I've being having a trouble, i have a jar, that a partner created to read from a webservice implementing some wsdl handling, this was created in netbeans.

So I want to use this jar, when i use it, i get a NoClassDefFoundError , I think it happens because there are some library collission, so look at this from the stack trace:

NoClassDefFoundError org.codehaus.xfire.jaxws.JAXWSHelper
[...]
org.codehaus.xfire.jaxws.Provider.createServiceDelegate(Provider.java:32)
javax.xml.ws.Service.<init>(Service.java:56)
org.ubl.soap.test.SubmissionAPI.<init>(SubmissionAPI.java:44)

I'm using libraries from javax.xml.ws so it uses Service.java , so in that class in sometime it uses the class javax.xml.ws.Provider , but for some reason, it takes the same class in other library from org.codehaus.xfire.jaxws .

org.codehaus.xfire.jaxws comes from xfire.jar and javax.xml.ws comes from two jars i use in my project, one is axis2 and the other is jaxws-api.jar.

First thing that crossed my mind is if it's being taken the classes from axis2 instead of jaxws-api.jar then maybe the classes in axis2 aren't working as they are older, so if i wanna use the classes from jaxws-api.jar instead of the ones in axis2 what should i do ?

In the classpath, the two of them are defined, so the sames classes are defined, in different jars, but the namespaces are the same and i can't just remove axis2 cuz there is some of it the system is using...

so I know the error NoDefFoundClass is a run-time error, so maybe it's build correctly but in run-time is taking the classes from xfire instead of axis2...

If you take a look at the javadoc of the Provider class: http://docs.oracle.com/javase/6/docs/api/javax/xml/ws/spi/Provider.html#provider()

It says there:

If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then its first line, if present, is used as the UTF-8 encoded name of the implementation class.

So, create that file and put the name of the Provider that you want to use into it.

The problem is that you call Provider.provider() and it returns the wrong one.

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