Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Osgi 如何排除java.lang.NoSuchMethodError故障?_Osgi_Apache Karaf_Wso2carbon_Nosuchmethoderror - Fatal编程技术网

Osgi 如何排除java.lang.NoSuchMethodError故障?

Osgi 如何排除java.lang.NoSuchMethodError故障?,osgi,apache-karaf,wso2carbon,nosuchmethoderror,Osgi,Apache Karaf,Wso2carbon,Nosuchmethoderror,我知道java.lang.NoSuchMethodError意味着用于编译的类的版本与运行时使用的版本不同。通常,当我看到这个问题时,我会在java-verbose模式下启动app.server,它告诉我类是从哪个jar文件加载的。如果这个jar文件不是我想要使用的,我知道我使用的jar文件版本不正确 我使用的另一种方法是使用javap查看我在运行时使用的jar文件中的类的方法签名,以确认jar确实包含具有不同方法签名的类 我现在在Karaf(一个OSGi容器)中看到了这个错误,上述方法都没有帮

我知道
java.lang.NoSuchMethodError
意味着用于编译的类的版本与运行时使用的版本不同。通常,当我看到这个问题时,我会在
java-verbose
模式下启动app.server,它告诉我类是从哪个jar文件加载的。如果这个jar文件不是我想要使用的,我知道我使用的jar文件版本不正确

我使用的另一种方法是使用
javap
查看我在运行时使用的jar文件中的类的方法签名,以确认jar确实包含具有不同方法签名的类

我现在在Karaf(一个OSGi容器)中看到了这个错误,上述方法都没有帮助
java-verbose
向我显示jar,
javap
向我显示方法签名,方法签名与错误跟踪中的签名相同。换句话说,我可以看到运行时使用的jar中的类确实具有jvm说找不到的相同方法签名

以下是确切的堆栈跟踪(如果有帮助):

java.lang.NoSuchMethodError: org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/axiom/soap/SOAPModelBuilder;
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:55)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:179)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.wso2.carbon.authenticator.stub.AuthenticationAdminStub.login(AuthenticationAdminStub.java:659)

我是否可以/应该使用其他方法?感谢您的帮助。

Karaf命令
导出[ID]
导入[ID]
类[ID]
可以与
grep
结合使用(每个命令都有一个
--help
选项)

从抛出错误(id为N)的包中,
imports N|grep org.apache.axiom.om
将告诉您它实际从哪个包导入该包

从另一方面来看,
exports | grep org.apache.axiom.om
将列出导出该包的包


我希望您能从导出中看到不止一行,并且import命令将显示正在使用的版本不正确。

您还可以使用java-verbose:class查看类从何处加载,这可能表明有问题的类是从您期望的不同包中加载的。

感谢您的响应。我已经表明我使用这种方法。你从哪里得到这个类?你是从服务中心得到的吗?您是否使用maven或任何依赖项管理库?您好,John,您最终解决了问题并找到了原因吗?我在这里也面临同样的问题。