下面的 Mule 流中的 Jersey class 有什么问题?
what is wrong with Jersey class in below Mule flow?
在下面的 mule 流程中,我为具有 VM 端点的 REST Web 服务实现了 Jersey class。
<flow name="APIKeyLoadFlow" doc:name="APIKeyLoadFlow"
initialState="started">
<http:inbound-endpoint exchange-pattern="request-response"
address="${api.load.invoke.url}" doc:name="HTTP"
responseTimeout="${apikey.http.responsetimeout}" />
<logger message="Start Of APIKeyLoadFlow -#[payload]" level="INFO"
doc:name="ENTRY_LOG" />
<request-reply timeout="300000" >
<vm:outbound-endpoint connector-ref="VM_Connector"
exchange-pattern="one-way" path="APIKeyLoadRequest">
</vm:outbound-endpoint>
<vm:inbound-endpoint connector-ref="VM_Connector"
exchange-pattern="one-way" path="APIKeyLoadResponse">
</vm:inbound-endpoint>
</request-reply>
<logger message="End of APIKeyLoadFlow" level="INFO" doc:name="EXIT_LOG" />
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger level="WARN" doc:name="Exception_Log"
message="Exception in ApiKeyFlow #[System.getProperty('line.separator')] Error Description = #[exception.getMessage()]" />
</catch-exception-strategy>
</flow>
<flow name="ApiKeyLoadRestServiceFlow" doc:name="ApiKeyLoadRestServiceFlow">
<vm:inbound-endpoint exchange-pattern="one-way"
path="APIKeyLoadRequest" doc:name="APIKey_Load_Request">
</vm:inbound-endpoint>
<logger message="Start of ApiKeyLoadRestServiceFlow -#[payload]" level="INFO"
doc:name="ENTRY_LOG" />
<jersey:resources doc:name="REST">
<component class="com.elexon.bmrs.apikey.service.impl.ApiKeyLoadImpl" />
</jersey:resources>
<logger message="End of ApiKeyLoadRestServiceFlow" level="INFO"
doc:name="EXIT_LOG" />
<vm:outbound-endpoint exchange-pattern="one-way"
path="APIKeyLoadResponse" doc:name="APIKey_Load_Response">
</vm:outbound-endpoint>
但是在 运行 请求时我遇到异常?请告诉我实施流程中的问题是什么?
INFO 2015-12-08 13:09:59,792 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor:APIKeyLoadFlow 开始 -org.apache.commons.httpclient.ContentLengthInputStream @1517f14
信息 2015-12-08 13:09:59,813 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager:正在初始化:'VM_Connector.dispatcher.25489136'。对象是:VMMessageDispatcher
信息 2015-12-08 13:09:59,813 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager:开始:'VM_Connector.dispatcher.25489136'。对象是:VMMessageDispatcher
信息 2015-12-08 13:09:59,830 [[apikey_load_phase3].ApiKeyLoadRestServiceFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor:ApiKeyLoadRestServiceFlow 开始 -org.apache.commons.httpclient.ContentLengthInputStream@1517f14
错误 2015-12-08 13:09:59,833 [[apikey_load_phase3].ApiKeyLoadRestServiceFlow.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
消息:无法调用 JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}。导致异常的组件是:JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}。消息负载的类型为:ContentLengthInputStream
代码:MULE_ERROR--2
异常堆栈是:
1.空(java.lang.NullPointerException)
org.mule.module.jersey.JerseyResourcesComponent:116(空)
2. 无法调用 JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}。导致异常的组件是:JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}。消息负载的类型为:ContentLengthInputStream (org.mule.component.ComponentException)
org.mule.component.AbstractComponent:144 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)
根异常堆栈跟踪:
java.lang.NullPointerException
在 org.mule.module.jersey.JerseyResourcesComponent.doInvoke(JerseyResourcesComponent.java:116)
在 org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:122)
在 org.mule.component.AbstractComponent.access$000(AbstractComponent.java:57)
+ 3 个(设置调试级别日志记录或 '-Dmule.verbose.exceptions=true' 一切)
Jersey 组件需要绑定到 http 端点,因此不确定它是否可以在 VM 端点后面工作,因为所有 http header 和请求信息在通过传输屏障等时都会丢失。你可以尝试在 vm 调用之前将 headers 从入站复制到出站,但仍然不确定这是否有效。
在下面的 mule 流程中,我为具有 VM 端点的 REST Web 服务实现了 Jersey class。
<flow name="APIKeyLoadFlow" doc:name="APIKeyLoadFlow"
initialState="started">
<http:inbound-endpoint exchange-pattern="request-response"
address="${api.load.invoke.url}" doc:name="HTTP"
responseTimeout="${apikey.http.responsetimeout}" />
<logger message="Start Of APIKeyLoadFlow -#[payload]" level="INFO"
doc:name="ENTRY_LOG" />
<request-reply timeout="300000" >
<vm:outbound-endpoint connector-ref="VM_Connector"
exchange-pattern="one-way" path="APIKeyLoadRequest">
</vm:outbound-endpoint>
<vm:inbound-endpoint connector-ref="VM_Connector"
exchange-pattern="one-way" path="APIKeyLoadResponse">
</vm:inbound-endpoint>
</request-reply>
<logger message="End of APIKeyLoadFlow" level="INFO" doc:name="EXIT_LOG" />
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger level="WARN" doc:name="Exception_Log"
message="Exception in ApiKeyFlow #[System.getProperty('line.separator')] Error Description = #[exception.getMessage()]" />
</catch-exception-strategy>
</flow>
<flow name="ApiKeyLoadRestServiceFlow" doc:name="ApiKeyLoadRestServiceFlow">
<vm:inbound-endpoint exchange-pattern="one-way"
path="APIKeyLoadRequest" doc:name="APIKey_Load_Request">
</vm:inbound-endpoint>
<logger message="Start of ApiKeyLoadRestServiceFlow -#[payload]" level="INFO"
doc:name="ENTRY_LOG" />
<jersey:resources doc:name="REST">
<component class="com.elexon.bmrs.apikey.service.impl.ApiKeyLoadImpl" />
</jersey:resources>
<logger message="End of ApiKeyLoadRestServiceFlow" level="INFO"
doc:name="EXIT_LOG" />
<vm:outbound-endpoint exchange-pattern="one-way"
path="APIKeyLoadResponse" doc:name="APIKey_Load_Response">
</vm:outbound-endpoint>
但是在 运行 请求时我遇到异常?请告诉我实施流程中的问题是什么?
INFO 2015-12-08 13:09:59,792 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor:APIKeyLoadFlow 开始 -org.apache.commons.httpclient.ContentLengthInputStream @1517f14 信息 2015-12-08 13:09:59,813 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager:正在初始化:'VM_Connector.dispatcher.25489136'。对象是:VMMessageDispatcher 信息 2015-12-08 13:09:59,813 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager:开始:'VM_Connector.dispatcher.25489136'。对象是:VMMessageDispatcher 信息 2015-12-08 13:09:59,830 [[apikey_load_phase3].ApiKeyLoadRestServiceFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor:ApiKeyLoadRestServiceFlow 开始 -org.apache.commons.httpclient.ContentLengthInputStream@1517f14 错误 2015-12-08 13:09:59,833 [[apikey_load_phase3].ApiKeyLoadRestServiceFlow.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
消息:无法调用 JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}。导致异常的组件是:JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}。消息负载的类型为:ContentLengthInputStream
代码:MULE_ERROR--2
异常堆栈是: 1.空(java.lang.NullPointerException) org.mule.module.jersey.JerseyResourcesComponent:116(空) 2. 无法调用 JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}。导致异常的组件是:JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}。消息负载的类型为:ContentLengthInputStream (org.mule.component.ComponentException)
org.mule.component.AbstractComponent:144 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)
根异常堆栈跟踪: java.lang.NullPointerException 在 org.mule.module.jersey.JerseyResourcesComponent.doInvoke(JerseyResourcesComponent.java:116) 在 org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:122) 在 org.mule.component.AbstractComponent.access$000(AbstractComponent.java:57) + 3 个(设置调试级别日志记录或 '-Dmule.verbose.exceptions=true' 一切)
Jersey 组件需要绑定到 http 端点,因此不确定它是否可以在 VM 端点后面工作,因为所有 http header 和请求信息在通过传输屏障等时都会丢失。你可以尝试在 vm 调用之前将 headers 从入站复制到出站,但仍然不确定这是否有效。