简体   繁体   English

编译时VS运行时

[英]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. 我遇到了麻烦,我有一个jar,是一个合作伙伴创建的,以从实现一些wsdl处理的Web服务中读取,这是在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 ,我认为这是因为存在一些库冲突,所以请从堆栈跟踪中查看:

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 . 我正在使用javax.xml.ws库,因此它使用Service.java ,因此在该类中有时会使用类javax.xml.ws.Provider ,但是由于某些原因,它在其他库中使用相同的类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. org.codehaus.xfire.jaxws来自xfire.jar,javax.xml.ws来自我在项目中使用的两个jar,一个是axis2,另一个是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 ? 我想到的第一件事是,如果要使用axis2中的类而不是jaxws-api.jar,那么也许Axis2中的类随着年龄的增长而不再起作用,所以如果我想使用jaxws-api.jar中的类而不是axis2中的那些我该怎么办?

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... 在类路径中,定义了它们中的两个,因此在不同的jar中定义了相同的类,但是名称空间是相同的,我不能只删除axis2,因为系统正在使用其中的一些...

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... 所以我知道错误NoDefFoundClass是运行时错误,所以它可能是正确构建的,但是在运行时从xfire而不是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() 如果您查看Provider类的javadoc: 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. 如果存在名称为META-INF / services / javax.xml.ws.spi.Provider的资源,则将其第一行(如果存在)用作实现类的UTF-8编码名称。

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. 问题是您调用Provider.provider()并返回错误的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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