mulemule-studiomule-componentmule-elmule-cluster

what is wrong with Jersey class in below Mule flow?


In the following mule flow, I have implemented Jersey class for REST web service with VM endpoints.

<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>

But i am getting below exception while running the request? Kindly let me what is the issue in the implemented flow?

INFO 2015-12-08 13:09:59,792 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: Start Of APIKeyLoadFlow -org.apache.commons.httpclient.ContentLengthInputStream@1517f14 INFO 2015-12-08 13:09:59,813 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'VM_Connector.dispatcher.25489136'. Object is: VMMessageDispatcher INFO 2015-12-08 13:09:59,813 [[apikey_load_phase3].connector.http.mule.default.receiver.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'VM_Connector.dispatcher.25489136'. Object is: VMMessageDispatcher INFO 2015-12-08 13:09:59,830 [[apikey_load_phase3].ApiKeyLoadRestServiceFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Start of ApiKeyLoadRestServiceFlow -org.apache.commons.httpclient.ContentLengthInputStream@1517f14 ERROR 2015-12-08 13:09:59,833 [[apikey_load_phase3].ApiKeyLoadRestServiceFlow.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:


Message : Failed to invoke JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}. Component that caused exception is: JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}. Message payload is of type: ContentLengthInputStream

Code : MULE_ERROR--2

Exception stack is: 1. null (java.lang.NullPointerException) org.mule.module.jersey.JerseyResourcesComponent:116 (null) 2. Failed to invoke JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}. Component that caused exception is: JerseyResourcesComponent{ApiKeyLoadRestServiceFlow.component.14630019}. Message payload is of type: ContentLengthInputStream (org.mule.component.ComponentException)

org.mule.component.AbstractComponent:144 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)

Root Exception stack trace: java.lang.NullPointerException at org.mule.module.jersey.JerseyResourcesComponent.doInvoke(JerseyResourcesComponent.java:116) at org.mule.component.AbstractComponent.invokeInternal(AbstractComponent.java:122) at org.mule.component.AbstractComponent.access$000(AbstractComponent.java:57) + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)



Solution

  • The Jersey component needs to be bound to an http endpoint, so not sure it can work behind a VM endpoint as all the http header and request information will be lost when passing a transport barrier etc. You could try copying the headers from inbound to outbound before the vm call, but still not sure this will work.