Мы переносим некоторые приложения из JBoss EAP 7.1.x в JBoss EAP 7.2.x.
Конечная точка JAX-WS развертывается на JBoss 7.2.x в автономном режиме с использованием standalone-full.xml,Эта конечная точка защищена WS-Security, а ее политики объявлены в wsdl.
Когда клиент отправляет запрос на эту конечную точку, появляется сообщение об ошибке, информирующее, что эти политики не могут быть выполнены.
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Receiver</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">
These policy alternatives can not be satisfied:
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}TransportBinding
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}TransportToken
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}HttpsToken
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}AlgorithmSuite
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Basic128
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Layout
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Lax
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}IncludeTimestamp
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}EndorsingSupportingTokens
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}X509Token
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}WssX509V3Token10
{http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}Wss11
</soap:Text>
</soap:Reason>
</soap:Fault>
Извлечение из server.log:
2019-10-09 09:41:31:633 FINE [org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader] (default task-1) Could not load or register WS-SecurityPolicy related classes. Please check that (the correct version of) Apache WSS4J is on the classpath: java.lang.ExceptionInInitializerError
at org.apache.cxf.ws.security.wss4j.WSS4JStaxOutInterceptor.<init>(WSS4JStaxOutInterceptor.java:92)
at org.apache.cxf.ws.security.wss4j.PolicyBasedWSS4JStaxOutInterceptor.<init>(PolicyBasedWSS4JStaxOutInterceptor.java:45)
at org.apache.cxf.ws.security.policy.interceptors.WSSecurityInterceptorProvider.<init>(WSSecurityInterceptorProvider.java:65)
at org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader.registerProviders(WSSecurityPolicyLoader.java:300)
at org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader.<init>(WSSecurityPolicyLoader.java:108)
(…)
Caused by: org.apache.xml.security.stax.ext.XMLSecurityConfigurationException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
Original Exception was org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
at org.apache.xml.security.stax.config.Init.init(Init.java:89)
at org.apache.wss4j.stax.setup.WSSec.<clinit>(WSSec.java:62)
... 106 more
Расследование показывает, что проблема возникает из-за возникновения исключительной ситуации при разборе файла wss-config.xml, расположенного в xmlsec-2.1.2.redhat-00001.jar. Эту проблему можно воспроизвести, вызвав эту строку в управляемой среде, даже вне контекста JAX-WS / CXF:
org.apache.xml.security.stax.config.Init.init(ClassLoaderUtils.getResource("wss/wss-config.xml", WSSec.class).toURI(), WSSec.class);
Строка, вызывающая исключение в org.apache.xml.security.stax.config.Init из xmlsec-2.1.2.redhat-00001.jar:
saxParser.parse(uri.toURL().toExternalForm(), new XIncludeHandler(unmarshallerHandler));
Эта ошибка, в частности, возникает в экземпляре 7.2.x в среде Redhat и не возникает:
- На экземпляре 7.2.x, установленном в среде Windows,
- На экземпляре 7.1.x, установленном в среде Redhat или Windows.
Конфигурация:
- ОС: RedHat 7.7
- Ядро: 3.10.0-1062.1.2.el7.x86_64
- Версия Java: openjdk version "1.8.0_222" Среда выполнения OpenJDK (build 1.8.0_222-b10) Виртуальная 64-битная серверная виртуальная машина OpenJDK (сборка 25.222-b10, смешанный режим)
- CXF-версия (из JBoss EAP 7.2.4): 3.2.9
Конфигурация конечной точки:
@WebContext(transportGuarantee = TransportGuarantee.CONFIDENTIAL, //
urlPattern = "/MyEndpoint")
@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "MyEndpoint")
public class MyEndPoint implements IMyEndPoint {
Используемый jboss-deploy-structure.xml:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.3">
<deployment>
<dependencies>
<module name="org.apache.cxf" export="true"/>
<module name="org.apache.cxf.impl" export="true"/>
<module name="org.apache.ws.security" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
Зависимость, объявленная в pom.xml:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>3.2.9</version>
<scope>provided</scope>
</dependency>
В чем может быть причина этой проблемы?