我正在尝试在 JBoss AS 7.1 上部署遗留代码,但由于 wss4j 和 xmlsec 而导致的依赖冲突,我正在努力解决冲突的依赖项
我创建了一个 jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding
some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.logmanager.log4j" />
<module name="org.slf4j" />
<module name="javaee.api" />
<module name="org.apache.santuario.xmlsec" />
</exclusions>
<dependencies>
<module name="javaee.api">
<imports>
<exclude-set>
<path name="org/apache/xml/security/**" />
<path name="org/apache/ws/security/**" />
</exclude-set>
</imports>
</module>
</dependencies>
</deployment>
但这会导致:
Caused by: java.lang.NoSuchMethodError: org.apache.xml.security.transforms.Transform.init()V
at org.apache.ws.security.WSSConfig.<init>(WSSConfig.java:81) [wss4j-1.5.1.jar:]
at org.apache.ws.security.WSSConfig.getNewInstance(WSSConfig.java:95) [wss4j-1.5.1.jar:]
at org.apache.ws.security.WSSConfig.<clinit>(WSSConfig.java:47) [wss4j-1.5.1.jar:]
at org.apache.ws.security.WSSecurityEngine.<clinit>(WSSecurityEngine.java:51) [wss4j-1.5.1.jar:]
at org.apache.ws.security.handler.WSHandler.<clinit>(WSHandler.java:62) [wss4j-1.5.1.jar:]
at com.realdolmen.forens2.service.kbo.impl.KBOConsultServiceImpl.signRequest(KBOConsultServiceI
当我将路径名更改为:
<exclude-set>
<path name="org/apache/xml/security" />
<path name="org/apache/ws/security" />
</exclude-set>
它导致:
Caused by: java.lang.NoSuchMethodError: org.apache.xml.security.keys.KeyInfo.init()V
at org.apache.xml.security.Init.init(Unknown Source) [xmlsec-1.3.0.jar:]
at org.apache.ws.security.WSSConfig.<init>(WSSConfig.java:72) [wss4j-1.5.1.jar:]
at org.apache.ws.security.WSSConfig.getNewInstance(WSSConfig.java:95) [wss4j-1.5.1.jar:]
真正让我发疯的是,正确的版本出现在堆栈跟踪中。
我已经用CXF重写了遗留代码。