MSF4J micoservice试图与SOAP服务进行通信

时间:2016-07-21 12:55:22

标签: axis2 wso2is axiom msf4j

我正在尝试使用MSF4J开发微服务。该服务获取输入请求的标头详细信息,并尝试与SOAP服务进行通信以进行进一步操作。当作为普通应用程序编写时,这个逻辑工作正常,但是当转换为微服务时,它会抛出以下异常

[org.apache.axis2.context.AbstractContext] : OnDemandLogger initialized for class org.apache.axis2.context.AbstractContext is:org.apache.commons.logging.internal.JclLogger@6b972f62
[org.apache.axis2.util.Loader] : Trying to find [org/apache/axis2/deployment/axis2_default.xml] using sun.misc.Launcher$AppClassLoader@73d16e93 class loader.
2016-07-21 17:45:48 ERROR ChannelChunkResponder:103 - Resource method threw an exception
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMethodInfo.java:95)
    at org.wso2.msf4j.internal.router.HttpDispatcher.channelRead0(HttpDispatcher.java:53)
    at org.wso2.msf4j.internal.router.HttpDispatcher.channelRead0(HttpDispatcher.java:31)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at org.wso2.msf4j.internal.router.RequestRouter.channelRead0(RequestRouter.java:83)
    at org.wso2.msf4j.internal.router.RequestRouter.channelRead0(RequestRouter.java:44)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:110)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodError: org.apache.axiom.om.OMAbstractFactory.getMetaFactory()Lorg/apache/axiom/om/OMMetaFactory;
    at org.apache.axiom.om.OMXMLBuilderFactory.createOMBuilder(OMXMLBuilderFactory.java:87)
    at org.apache.axiom.om.OMXMLBuilderFactory.createOMBuilder(OMXMLBuilderFactory.java:73)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:590)
    at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:575)
    at org.apache.axis2.deployment.DescriptionBuilder.buildOM(DescriptionBuilder.java:97)
    at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:91)
    at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:887)
    at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:116)
    at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
    at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:210)
    at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:150)
    at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:143)
    at org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub.<init>(OAuth2TokenValidationServiceStub.java:103)
    at org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub.<init>(OAuth2TokenValidationServiceStub.java:89)
    at com.wipro.oauth.manager.IDManagementClient.validateToken(IDManagementClient.java:220)
    at com.wipro.oauth.manager.IdentityServerRest.getOAuthToken(IdentityServerRest.java:126)
    ... 37 more

SOAP服务,微服务尝试与之通信的是&#34; OAuth2TokenValidationService&#34; WSO2身份服务器。

包含对SAOP服务的调用的方法如下

 public OAuth2TokenValidationResponseDTO validateToken(
                String accessTokenIdentifier)
                throws RemoteException, LoginAuthenticationExceptionException {


            OAuth2TokenValidationServiceStub stub = new OAuth2TokenValidationServiceStub(
                    null, server
                            + "/services/OAuth2TokenValidationService");

            ServiceClient e3 = stub._getServiceClient();
            Options option3 = e3.getOptions();
            HttpTransportProperties.Authenticator auth1 = new HttpTransportProperties.Authenticator();
            auth1.setUsername(utUsername);
            auth1.setPassword(utPassword);
            auth1.setPreemptiveAuthentication(true);
            option3.setManageSession(true);
            /*option2.setProperty(Constants.Configuration.MESSAGE_TYPE,HTTPConstants.MEDIA_TYPE_APPLICATION_ECHO_XML);
            option2.setProperty(Constants.Configuration.DISABLE_SOAP_ACTION,Boolean.TRUE);*/
            option3.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth1);
            /*option2.setProperty("Cookie", authCookie);*/
            e3.setOptions(option3);

            OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();

            OAuth2TokenValidationRequestDTO_OAuth2AccessToken accessToken = new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
            accessToken.setTokenType("Bearer");
            accessToken.setIdentifier(accessTokenIdentifier);
            oauthReq.setAccessToken(accessToken);
            oauthReq.setRequiredClaimURIs(null);

            OAuth2TokenValidationResponseDTO resp = stub.validate(oauthReq);


return resp;
    }

在将普通应用程序转换为微服务时添加了以下依赖项。

<dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.transport</artifactId>
            <version>5.0.0-alpha</version>
             <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

与AXIOM相关的依赖项是

    <dependency>
                    <groupId>org.apache.ws.commons.axiom.wso2</groupId>
                    <artifactId>axiom</artifactId>
                    <version>1.2.11.wso2v4</version>
                </dependency> 
    <dependency>
        <groupId>org.apache.woden</groupId>
        <artifactId>woden-impl-dom</artifactId>
        <version>1.0M8</version>
</dependency>

非常感谢您解决此问题的任何帮助。

1 个答案:

答案 0 :(得分:2)

您能否尝试使用最新的MSF4J 2.0版本?

此问题的根本原因是:引起:java.lang.NoSuchMethodError:org.apache.axiom.om.OMAbstractFactory.getMetaFactory()Lorg / apache / axiom / om / OMMetaFactory;

这意味着,在依赖关系树中,很可能另一个版本的Axiom作为传递依赖进入。

运行; mvn依赖:树并找出其他版本的Axiom被引入并从Maven构建中排除这些版本。