Pointers mule restful代理引发空指针异常

Pointers mule restful代理引发空指针异常,pointers,exception,null,mule,Pointers,Exception,Null,Mule,我正在使用mule构建一个简单的restful代理。虽然大多数rest调用都已正确代理,但其中一个POST调用引发空指针异常 以下是入站消息: org.mule.DefaultMuleMessage { id=c856d080-bd55-11e4-8504-6c40089d7cb6 payload=java.lang.String correlationId=<not set> correlationGroup=-1 correlationSeq=-1 enc

我正在使用mule构建一个简单的restful代理。虽然大多数rest调用都已正确代理,但其中一个POST调用引发空指针异常

以下是入站消息:

org.mule.DefaultMuleMessage
{
  id=c856d080-bd55-11e4-8504-6c40089d7cb6
  payload=java.lang.String
  correlationId=<not set>
  correlationGroup=-1
  correlationSeq=-1
  encoding=UTF-8
  exceptionPayload=<not set>

Message properties:
  INVOCATION scoped properties:
  INBOUND scoped properties:
    accept=text/virl+xml,multipart/mixed
    authorization=Basic TmV0U2ltOk5ldFNpbQ==
    connection=keep-alive
    content-length=1000
    content-type=application/xml
    host=localhost:9090
    http.listener.path=/*
    http.method=POST
    http.query.params=org.mule.module.http.internal.ParameterMap@330eee18
    http.query.string=session=0c603343-49e6-452f-bfdf-1e69cf478f65
    http.remote.address=/127.0.0.1:52065
    http.request.path=/ank/rest/process
    http.request.uri=/ank/rest/process?session=0c603343-49e6-452f-bfdf-1e69cf478f65
    http.scheme=http
    http.uri.params=org.mule.module.http.internal.ParameterMap@0
    http.version=HTTP/1.1
    user-agent=Jersey/2.0-rc1 (HttpUrlConnection 1.7.0_71)
  OUTBOUND scoped properties:
    Content-Type=text/plain;charset=UTF-8
    MULE_ENCODING=UTF-8
    http.disable.status.code.exception.check=false
  SESSION scoped properties:
}
ERROR 2015-02-25 19:21:26,894 [[restproxy].VIRL-UWM-Management-APIs.worker.02] org.mule.exception.CatchMessagingExceptionStrategy: 
********************************************************************************
Message               : null (java.lang.NullPointerException). Message payload is of type: String
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
  org.mule.module.http.internal.HttpParser:94 (null)
2. null (java.lang.NullPointerException). Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
    at org.mule.module.http.internal.HttpParser.parseMultipartContent(HttpParser.java:94)
    at org.mule.module.http.internal.request.HttpResponseToMuleEvent.getInboundAttachments(HttpResponseToMuleEvent.java:139)
    at org.mule.module.http.internal.request.HttpResponseToMuleEvent.convert(HttpResponseToMuleEvent.java:77)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
org.mule.DefaultMuleMessage
{
id=c856d080-bd55-11e4-8504-6c40089d7cb6
有效负载=java.lang.String
相关ID=
correlationGroup=-1
correlationSeq=-1
编码=UTF-8
例外有效载荷=
消息属性:
调用范围的属性:
入站作用域属性:
accept=text/virl+xml,多部分/混合
授权=基本TmV0U2ltOk5ldFNpbQ==
连接=保持活动状态
内容长度=1000
内容类型=应用程序/xml
主机=本地主机:9090
http.listener.path=/*
http.method=POST
http.query.params=org.mule.module.http.internal。ParameterMap@330eee18
http.query.string=session=0c603343-49e6-452f-bfdf-1e69cf478f65
http.remote.address=/127.0.0.1:52065
http.request.path=/ank/rest/process
http.request.uri=/ank/rest/process?session=0c603343-49e6-452f-bfdf-1e69cf478f65
scheme=http
http.uri.params=org.mule.module.http.internal。ParameterMap@0
http.version=http/1.1
用户代理=Jersey/2.0-rc1(HttpUrlConnection 1.7.0_71)
出站作用域属性:
内容类型=文本/普通;字符集=UTF-8
MULE_编码=UTF-8
http.disable.status.code.exception.check=false
会话作用域属性:
}
错误2015-02-25 19:21:26894[[restproxy].VIRL-UWM-Management-api.worker.02]org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
消息:null(java.lang.NullPointerException)。消息负载的类型为:String
代码:MULE_错误--2
--------------------------------------------------------------------------------
异常堆栈是:
1.null(java.lang.NullPointerException)
org.mule.module.http.internal.HttpParser:94(空)
2.null(java.lang.NullPointerException)。消息负载的类型为:String(org.mule.api.MessaginException)
org.mule.execution.ExceptionToMessaginExceptionExecutionInterceptor:32(http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
根异常堆栈跟踪:
java.lang.NullPointerException
位于org.mule.module.http.internal.HttpParser.parseMultipartContent(HttpParser.java:94)
位于org.mule.module.http.internal.request.HttpResponseToMuleEvent.getInboundAttachments(HttpResponseToMuleEvent.java:139)
位于org.mule.module.http.internal.request.HttpResponseToMuleEvent.convert(HttpResponseToMuleEvent.java:77)
+3个以上(为所有内容设置调试级别日志或“-Dmule.verbose.exceptions=true”)
********************************************************************************
不知道为什么它会失败。通过传递代理来命中实际端点可以正常工作。有什么线索吗

骡流:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    <http:listener-config name="VIRL-UWM-Management-APIs" host="0.0.0.0" port="9090" doc:name="HTTP Listener Configuration"/>
    <http:request-config name="Actual-Virl-Enpoint-for-UWM" host="virl03.stic.cisco-services.com" port="19399" doc:name="HTTP Request Configuration"/>
    <http:listener-config name="AutoNetKit-API" host="0.0.0.0" port="19401" doc:name="HTTP Listener Configuration"/>
    <http:request-config name="AutoNetkit-End-Point" host="virl03.stic.cisco-services.com" port="19401" doc:name="HTTP Request Configuration"/>
    <flow name="virl-proxyFlow">
        <http:listener config-ref="AutoNetKit-API" path="*" allowedMethods="GET" doc:name="HTTP"/>
        <set-property propertyName="http.disable.status.code.exception.check" value="false" doc:name="Disable Exception Check"/>
        <logger message=" payload is: #[message.payload], method is: #[message.inboundProperties.'http.method'], Request URI is: #[message.inboundProperties.'http.request.uri'], message is: #[message]" level="INFO" doc:name="Logger"/>
        <flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>
        <http:request config-ref="AutoNetkit-End-Point" path="#[message.inboundProperties.'http.request.uri']" method="#[message.inboundProperties.'http.method']" responseTimeout="60000" doc:name="AutoNetKit-EndPoint"/>
        <flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>
    </flow>
    <flow name="VIRL-Restful-Proxy">
        <http:listener config-ref="VIRL-UWM-Management-APIs" path="*" doc:name="HTTP"/>
        <choice doc:name="GET-vs-POST">
            <when expression="#[message.inboundProperties.'http.method' == 'POST']">
                <object-to-string-transformer doc:name="Object to String"/>
                <logger message="Set the payload of type string - since it's a post request." level="INFO" doc:name="Logger"/>
            </when>
            <otherwise>
                <logger message="Not setting payload transformation as it's a GET request." level="INFO" doc:name="Logger"/>
            </otherwise>
        </choice>

        <set-property propertyName="http.disable.status.code.exception.check" value="false" doc:name="Disable Exception Check"/>

        <logger message=" payload is: #[message.payload], method is: #[message.inboundProperties.'http.method'], Request URI is: #[message.inboundProperties.'http.request.uri'], message is: #[message]" level="INFO" doc:name="Logger"/>
        <flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>

        <http:request config-ref="Actual-Virl-Enpoint-for-UWM" path="#[message.inboundProperties.'http.request.uri']" 
                        method="#[message.inboundProperties.'http.method']" responseTimeout="60000" doc:name="VIRL End Point"/>
        <logger message="response payload: #[message]" level="INFO" doc:name="Logger"/>

        <flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>


        <catch-exception-strategy doc:name="Catch Exception Strategy">
            <logger level="DEBUG" message="#[exception.exceptions]" doc:name="Logger"/>
        </catch-exception-strategy>


    </flow>

        <sub-flow name="copy-headers" >
        <copy-properties propertyName="*" doc:name="Copy All HTTP Headers"/>
        <remove-property propertyName="Content-Length" doc:name="Remove Content Length"/>
        <remove-property propertyName="MULE_*" doc:name="Remove MULE Properties"/>
        <remove-property propertyName="X_MULE*" doc:name="Remove X_MULE Properties"/>
        <remove-property propertyName="X-MULE*" doc:name="Remove X-MULE Properties"/>
    </sub-flow>



</mule>


谢谢

这是Mule代码中的一个bug:我已经报告过了,您可以跟踪它

同时,您可以尝试以下方法:

  • 如果您可以控制远程服务器,请在其多部分响应中添加
    内容处置
    标题
  • 暂时使用
    http:outbound端点
    代替
    http:request
    ,直到上述错误得到修复

Mule版本?流程配置?堆栈跟踪?更多信息或我们无法帮助。这是当前版本-今天刚下载。更新了mule流程。就堆栈跟踪而言,这就是我在anypoint studio控制台中看到的所有内容。感谢提供详细信息。如果使用
-Dmule.verbose.exceptions=true运行应用程序,则会出现更详细的异常。现在,我想你已经提供了足够的信息。谢谢大卫。我能够通过http:outbound端点解决这个问题。然而,我遇到了另一个问题。我现在得到web套接字调用的响应代码304。这是一个已知的问题吗?谢谢大卫。Mule支持websocket调用吗?以下是路由web套接字调用时得到的结果:异常为:org.mule.api.transport.DispatchException:未能通过端点路由事件:DefaultOutboundEndpoint{endpointUri=,connector=HttpPollingConnectormore异常详细信息。{name=HTTP_Polling lifecycle=start this=236ce4be numberofConcurrentTransacticedReceiver=4 createMultipleTransacticedReceiver=true connected=true supportedProtocols=[HTTP]serviceOverrides=message.receiver=org.mule.transport.HTTP.PollingHttpMessageReceiver}这值得我提出另一个问题。在任何情况下,答案都是否定的,
http:outbound endpoint
不支持WebSocket。新的请求连接器似乎也不支持WebSocket:文档中没有提到代理WebSocket并不是小事,因为Mule需要维护到远程主机的连接,并以某种方式将它们作为WebSocket重新公开凯茨?