我正在将我的AXIS 1网络服务演进到AXIS 2,我已经成功地部署了没有处理程序的网络服务,它们运行得很好,但现在,我正试图添加处理程序,以便处理SOAP头(安全原因)。在AXIS 1中,我在WSDD文件中定义了处理程序,但根据AXIS 2的文档,现在我需要定义一个模块,以便将处理程序包含到AXIS引擎中。然而,在我的WildFly服务器上部署服务后,我向服务发送了一个SOAP请求,并得到以下响应。
<html>
<head>
...
</head>
<body>
<div class="header">
<div class="error-div"/>
<div class="error-text-div">Error processing request</div>
</div>
<div class="label">Context Path:</div>
<div class="value">/pao</div>
<br/>
<div class="label">Servlet Path:</div>
<div class="value">/services</div>
<br/>
<div class="label">Path Info:</div>
<div class="value">/PAOSynchronizationServiceSOAP</div>
<br/>
<div class="label">Query String:</div>
<div class="value">null</div>
<br/>
<b>Stack Trace</b>
<br/>
javax.servlet.ServletException: javax.servlet.ServletException: org.apache.axis2.deployment.DeploymentException: org.apache.axis2.dispatchers.RequestURIBasedDispatcher cannot be cast to org.apache.axis2.engine.Handler
<br/>
org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:479)
<br/>
io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
<br/>
org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
<br/>
io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
<br/>
io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
<br/>
io.undertow.servlet.core.ManagedServlet.getServlet(ManagedServlet.java:171)
<br/>
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:84)
<br/>
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
<br/>
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
<br/>
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
<br/>
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
<br/>
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
<br/>
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
<br/>
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
<br/>
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
<br/>
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
<br/>
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
<br/>
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
<br/>
io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
<br/>
io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
<br/>
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
<br/>
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
<br/>
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
<br/>
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
<br/>
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
<br/>
io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
<br/>
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
<br/>
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
<br/>
io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
<br/>
io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
<br/>
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
<br/>
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
<br/>
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
<br/>
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
<br/>
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
<br/>
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
<br/>
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
<br/>
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
<br/>
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
<br/>
io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
<br/>
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
<br/>
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
<br/>
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
<br/>
java.lang.Thread.run(Thread.java:748)
<br/>
</body>
而在我的应用日志中,我可以看到这样的内容:
2020-05-18 11:43:24,418 DEBUG [org.apache.axis2.transport.http.AxisServlet] (default task-3) OnDemandLogger initialized for class org.apache.axis2.transport.http.AxisServlet is:org.apache.commons.logging.impl.SLF4JLocationAwareLog@2500e603
2020-05-18 11:43:24,418 INFO [org.apache.axis2.transport.http.AxisServlet] (default task-3)
org.apache.axis2.deployment.DeploymentException: org.apache.axis2.dispatchers.RequestURIBasedDispatcher cannot be cast to org.apache.axis2.engine.Handler
2020-05-18 11:43:24,419 ERROR [io.undertow.request] (default task-3) UT005023: Exception handling request to /pao/services/PAOSynchronizationServiceSOAP: javax.servlet.ServletException: javax.servlet.ServletException: org.apache.axis2.deployment.DeploymentException: org.apache.axis2.dispatchers.RequestURIBasedDispatcher cannot be cast to org.apache.axis2.engine.Handler
at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:479)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
at io.undertow.servlet.core.ManagedServlet.getServlet(ManagedServlet.java:171)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.servlet.ServletException: org.apache.axis2.deployment.DeploymentException: org.apache.axis2.dispatchers.RequestURIBasedDispatcher cannot be cast to org.apache.axis2.engine.Handler
at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:627)
at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:471)
... 43 more
Caused by: org.apache.axis2.deployment.DeploymentException: org.apache.axis2.dispatchers.RequestURIBasedDispatcher cannot be cast to org.apache.axis2.engine.Handler
at org.apache.axis2.deployment.util.Utils.loadHandler(Utils.java:148)
at org.apache.axis2.deployment.AxisConfigBuilder.processPhaseList(AxisConfigBuilder.java:575)
at org.apache.axis2.deployment.AxisConfigBuilder.processPhaseOrders(AxisConfigBuilder.java:606)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:149)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:629)
at org.apache.axis2.deployment.WarBasedAxisConfigurator.<init>(WarBasedAxisConfigurator.java:157)
at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:620)
... 44 more
Caused by: java.lang.ClassCastException: org.apache.axis2.dispatchers.RequestURIBasedDispatcher cannot be cast to org.apache.axis2.engine.Handler
at org.apache.axis2.deployment.util.Utils.loadHandler(Utils.java:133)
... 50 more
我使用maven插件 "axis2-repo-maven-plugin "来生成.mar和.list文件。 services.xml是这样的。
<service name="PAOSynchronizationServiceSOAP" targetNamespace="urn:es:pao:services:messages:1.0.0">
<description>Servicios PAO.</description>
<module ref="AuthModule" />
<schema schemaNamespace="urn:es:pao:services:messages:1.0.0" />
<parameter name="ServiceClass" locked="false">es.gob.afirma.pao.impl.PAOSynchronizationServiceSOAPBindingImpl
</parameter>
<!-- <parameter name="disableSOAP11" locked="true">true</parameter> -->
<parameter name="disableREST" locked="false">true</parameter>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
class="es.gob.afirma.pao.utilities.PAOSynchronizationServiceMessageReceiverInOut" />
</messageReceivers>
</service>
模块.xml。
<module name="AuthModule" class="es.gob.afirma.pao.utilities.AuthModule">
<InFlow>
<handler name="AuthHandler" class="es.gob.afirma.pao.impl.AuthHandler">
<order phase="Security" />
</handler>
</InFlow>
<OutFlow>
</OutFlow>
<OutFaultFlow>
</OutFaultFlow>
<InFaultFlow>
</InFaultFlow>
模块的实现是默认的(方法为空),处理程序扩展到AbstractHandler类。
我做错了什么?
最后,我发现了问题所在。我添加了 "rampart "依赖,它与其他Axis库有冲突,所以在阶段性加载过程中,Axis引擎在投递处理程序时崩溃。
我使用 "rampart "依赖关系来执行 "axis2-mar-maven-plugin "maven插件(按照本指南)但最后我在axis2.xml文件中添加了处理程序,所以,我不需要定义Axis模块。