Weblogic java.lang.NoSuchMethodError:org.apache.xml.security.encryption.XMLCipher.manual(文档;引用列表;)
我正在尝试使用此调用加密我的XMl:Weblogic java.lang.NoSuchMethodError:org.apache.xml.security.encryption.XMLCipher.manual(文档;引用列表;),weblogic,xmlsec,Weblogic,Xmlsec,我正在尝试使用此调用加密我的XMl: XMlCipher.martial(Document context,ReferenceList referenceList) 为此,项目引用了xmlsec-1.5.3.jar 我能够在weblogic服务器上成功地构建和部署代码,但在执行后,我在日志中发现以下错误 Caused by: java.lang.NoSuchMethodError: org.apache.xml.security.encryption.XMLCipher.martial(Lo
XMlCipher.martial(Document context,ReferenceList referenceList)
为此,项目引用了xmlsec-1.5.3.jar
我能够在weblogic服务器上成功地构建和部署代码,但在执行后,我在日志中发现以下错误
Caused by: java.lang.NoSuchMethodError:
org.apache.xml.security.encryption.XMLCipher.martial(Lorg/w3c/dom/Document;Lorg/apache/xml/security/encryption/ReferenceList;)Lorg/w3c/dom/Element;
at com.ally.util.encryption.EncryptionUtil.generateEncryptedXML(EncryptionUtil.java:381)
at com.ally.util.encryption.EncryptionUtil.getEnryptedXMLDocument(EncryptionUtil.java:443)
at com.ally.partner.fis.acctinq.FISSoapHandler.getFISEncryptedHeader(FISSoapHandler.java:154)
这种错误总是由类路径上有多个XMlCipher引用引起的。它可以是一个重复的xmlsec.jar,也可以是另一个jar中的xmlchipher的另一个实例 您有几个选项可以调试该问题: 编辑war文件以删除重复的jar和/或XMlCipher类的不同版本 使用jconsole连接到weblogic托管服务器并查看类路径。看看是否注意到包含了xmlsec.jar的另一个实例 您可能需要通过在weblogic.xml中指定以下内容来告诉weblogic更喜欢位于.war/.ear文件中的类的实例:
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.apache.xml.security.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
有关更多详细信息和类似问题,请参见:我知道您没有提到Maven或SoapUI的使用,但我在尝试使用soapui maven插件时收到了一个类似的异常java.lang.NoSuchMethodError:org.apache.xml.security.encryption.XMLCipher.setSecureValidation,我想发布我的解决方案以期有所帮助 对我来说,修复方法是在pom.xml中的soapui maven插件中添加一个xml安全依赖项,如下所示:
<!-- To run, enter this command from the module directory: mvn soapui:test -->
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.1.1</version>
<dependencies>
<dependency>
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
<configuration>
<projectFile>src/test/soap-ui/your-soapui-xml-file.xml</projectFile>
</configuration>
</plugin>
</plugins>
在我的例子中,我在项目的其他地方没有xml安全依赖关系
在其他情况下,似乎有些人可能会遇到这种错误,因为他们的项目中有多个xml安全依赖项,而且它们相互冲突,就像一个答案已经提到的那样。因此,如果上述修复在该场景中对您不起作用,您可能需要查看项目中的哪些依赖项包括xml安全性,并决定要包括哪些依赖项以及要排除哪些依赖项,例如使用Maven的排除或给定pom中提供的范围标记