I have following Mule flow :-
<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<mule-ss:security-manager>
<mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" />
</mule-ss:security-manager>
<spring:beans>
<ss:authentication-manager alias="authenticationManager">
<ss:authentication-provider>
<ss:user-service id="userService">
<ss:user name="username" password="password" authorities="ROLE_ADMIN" />
</ss:user-service>
</ss:authentication-provider>
</ss:authentication-manager>
</spring:beans>
<flow name="testFlow1" doc:name="testFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8083" doc:name="HTTP">
<mule-ss:http-security-filter realm="realm" />
</http:inbound-endpoint>
<jersey:resources doc:name="REST">
<component class="MyRest" />
</jersey:resources>
<logger message="Done !!!!!" level="INFO" doc:name="Logger"/>
<!-- http://username:password#localhost:8083/myrest or http://localhost:8083/myrest and in this case we need to provide username and password from browser-->
<catch-exception-strategy>
<choice >
<when expression="#[exception.getCauseException().getClass().getName()=='org.springframework.security.authentication.BadCredentialsException']">
<logger level="INFO" message="Authentication failed exception: #[exception.getCauseException().getClass().getName()]"/>
<set-property propertyName="http.status" value="401"/>
<http:response-builder status="401" doc:name="Status code = 401" doc:description="Authentication failed"/>
</when>
<when expression="#[exception.getCauseException().getClass().getName()=='org.springframework.security.access.AccessDeniedException']">
<logger level="INFO" message="Access denied exception: #[exception.getCauseException().getClass().getName()]"/>
<set-property propertyName="http.status" value="405"/>
<http:response-builder status="405" doc:name="Status code = 405" doc:description="Authorization exception - Access denied"/>
</when>
<otherwise>
<logger message="An exception has been caught: #[exception.getCauseException().getClass().getName()]" level="ERROR" doc:name="Exception Thrown"/>
<set-payload value="Error detected while processing" doc:name="Prepare response for client"/>
<set-property propertyName="http.status" value="500"/>
<http:response-builder status="500" doc:name="Status code = 500" doc:description="Exception - Sending a 500 Http Status code as Response"/>
</otherwise>
</choice>
</catch-exception-strategy>
</flow>
I have taken the following as reference :- https://github.com/daveEason/mule-example-spring-security/blob/master/src/main/app/mule-config.xml
Now the issue whenever I hit the url :- http://localhost:8083/myrest ... I get the following exception :-
ERROR 2014-10-20 23:06:52,223 [[test].connector.http.mule.default.receiver.03] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : Registered authentication is set to org.mule.module.spring.security.filters.http.HttpBasicAuthenticationFilter but there was no security context on the session. Authentication denied on endpoint http://localhost:8083. Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Registered authentication is set to org.mule.module.spring.security.filters.http.HttpBasicAuthenticationFilter but there was no security context on the session. Authentication denied on endpoint http://localhost:8083. Message payload is of type: String (org.mule.api.security.UnauthorisedException)
org.mule.transport.http.filters.HttpBasicAuthenticationFilter:156 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/security/UnauthorisedException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.security.UnauthorisedException: Registered authentication is set to org.mule.module.spring.security.filters.http.HttpBasicAuthenticationFilter but there was no security context on the session. Authentication denied on endpoint http://localhost:8083. Message payload is of type: String
at org.mule.transport.http.filters.HttpBasicAuthenticationFilter.authenticateInbound(HttpBasicAuthenticationFilter.java:156)
at org.mule.security.AbstractEndpointSecurityFilter.authenticate(AbstractEndpointSecurityFilter.java:54)
at org.mule.security.AbstractAuthenticationFilter.doFilter(AbstractAuthenticationFilter.java:52)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR 2014-10-20 23:06:52,225 [[test].connector.http.mule.default.receiver.03] org.mule.api.processor.LoggerMessageProcessor: An exception has been caught: org.mule.api.security.UnauthorisedException
ERROR 2014-10-20 23:06:52,520 [[test].connector.http.mule.default.receiver.03] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : Registered authentication is set to org.mule.module.spring.security.filters.http.HttpBasicAuthenticationFilter but there was no security context on the session. Authentication denied on endpoint http://localhost:8083. Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Registered authentication is set to org.mule.module.spring.security.filters.http.HttpBasicAuthenticationFilter but there was no security context on the session. Authentication denied on endpoint http://localhost:8083. Message payload is of type: String (org.mule.api.security.UnauthorisedException)
org.mule.transport.http.filters.HttpBasicAuthenticationFilter:156 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/security/UnauthorisedException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.security.UnauthorisedException: Registered authentication is set to org.mule.module.spring.security.filters.http.HttpBasicAuthenticationFilter but there was no security context on the session. Authentication denied on endpoint http://localhost:8083. Message payload is of type: String
at org.mule.transport.http.filters.HttpBasicAuthenticationFilter.authenticateInbound(HttpBasicAuthenticationFilter.java:156)
at org.mule.security.AbstractEndpointSecurityFilter.authenticate(AbstractEndpointSecurityFilter.java:54)
at org.mule.security.AbstractAuthenticationFilter.doFilter(AbstractAuthenticationFilter.java:52)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR 2014-10-20 23:06:52,522 [[test].connector.http.mule.default.receiver.03] org.mule.api.processor.LoggerMessageProcessor: An exception has been caught: org.mule.api.security.UnauthorisedException
I wonder why it's generating such exception ..
But if I remove the exception block from the code and hit http://localhost:8083/myrest it works fine and ask the username and password as expected and generate expected result ..
But I wonder why it is generating exception when I am using exception block in the code ..
Actually my intention of using exception block is to get and control different http status in different situation
There are two things at play here:
Exceptions thrown by the Jersey resources
Such exceptions must be dealt with by one or several custom JAX-RS exception handlers, registered to jersey:resources via one or several jersey:exception-mapper elements.
Exceptions thrown by mule-ss:http-security-filter
These exceptions are thrown by Mule outside of the scope of JAX-RS, so they must be handled by a catch-exception-strategy element, as you did in your question.
Having this combination of error handling should provide you with what you need.
to retrieve the HTTP code you can use a filter and throw an exception in the flow. Here an example:
<message-filter throwOnUnaccepted="true">
<message-property-filter pattern="message.inboundProperties['http.status'] >= 400" />
</message-filter>
Related
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)
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.
I tried to integrate linkedin with mule. I successfully authorize user and also get my profile information.
But I couldn't change my current status.. And I couldn't get user updates.
I got following error
Message : Could not find a transformer to transform "SimpleDataType{type=java.lang.String, mimeType='*/*'}" to "CollectionDataType{type=java.util.List, itemType=java.lang.Object, mimeType='*/*'}".
Code : MULE_ERROR-65237
--------------------------------------------------------------------------------
Exception stack is:
1. Could not find a transformer to transform "SimpleDataType{type=java.lang.String, mimeType='*/*'}" to "CollectionDataType{type=java.util.List, itemType=java.lang.Object, mimeType='*/*'}". (org.mule.api.transformer.TransformerException)
org.mule.registry.MuleRegistryHelper:268 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.transformer.TransformerException: Could not find a transformer to transform "SimpleDataType{type=java.lang.String, mimeType='*/*'}" to "CollectionDataType{type=java.util.List, itemType=java.lang.Object, mimeType='*/*'}".
at org.mule.registry.MuleRegistryHelper.lookupTransformer(MuleRegistryHelper.java:268)
at org.mule.module.linkedin.processors.AbstractExpressionEvaluator.transform(AbstractExpressionEvaluator.java:279)
at org.mule.module.linkedin.processors.AbstractExpressionEvaluator.evaluateAndTransform(AbstractExpressionEvaluator.java:202)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
My flow is as follow
<flow name="linkedinFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="auth" doc:name="HTTP"/>
<linkedin:authorize config-ref="LinkedIn" doc:name="LinkedIn"/>
</flow>
<flow name="linkedinFlow2">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="userupdates" doc:name="HTTP"/>
<linkedin:get-user-updates config-ref="LinkedIn" doc:name="LinkedIn">
<linkedin:update-types ref="#[payload]"/>
</linkedin:get-user-updates>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
How can I get user user updates??
I also Tried following code
<flow name="linkedinFlow3">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8090" path="userupdates1" doc:name="HTTP" />
<linkedin:get-network-updates config-ref="LinkedIn" start="10"
count="20"
showHiddenMembers="true"
startDate="2011-08-10T00:00:00-00:00"
endDate="2015-05-10T00:00:00-00:00">
<linkedin:update-types>
<linkedin:update-type>PROFILE_UPDATE</linkedin:update-type>
<linkedin:update-type>RECOMMENDATION_UPDATE</linkedin:update-type>
</linkedin:update-types>
</linkedin:get-network-updates>
</flow>
Then I got following error
Exception stack is:
1. Access to network denied (com.google.code.linkedinapi.client.LinkedInApiClientException)
com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient:2088 (null)
2. Failed to invoke getNetworkUpdates. Message payload is of type: String (org.mule.api.MessagingException)
org.mule.module.linkedin.processors.GetNetworkUpdatesMessageProcessor:189 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
I also change the scope rw_nus+r_basicprofile but got 403 error my page didn't authenticate
If I used rw_company_admin scope I can authenticate succesfully but didn't get success in geting user updates
How can I solve this problem?please help
I'm new to Mule and while working on a fairly simple Hello World example on Anypoint Studio to test out the Scatter/Gather flow control element, I'm getting the following error, without much else in the way of information:
ERROR 2014-12-19 22:00:30,172 [[unifinesb].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Exception was found for route(s): 0. Message payload is of type: String
Type : org.mule.routing.CompositeRoutingException
Code : MULE_ERROR--2
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/routing/CompositeRoutingException.html
Payload : /Waldo
********************************************************************************
Exception stack is:
1. Exception was found for route(s): 0. Message payload is of type: String (org.mule.routing.CompositeRoutingException)
org.mule.routing.CollectAllAggregationStrategy:51 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/routing/CompositeRoutingException.html)
********************************************************************************
Root Exception stack trace:
org.mule.routing.CompositeRoutingException: Exception was found for route(s): 0. Message payload is of type: String
at org.mule.routing.CollectAllAggregationStrategy.aggregateWithFailedRoutes(CollectAllAggregationStrategy.java:51)
at org.mule.routing.CollectAllAggregationStrategy.aggregate(CollectAllAggregationStrategy.java:38)
at org.mule.routing.ScatterGatherRouter.processResponses(ScatterGatherRouter.java:207)
at org.mule.routing.ScatterGatherRouter.process(ScatterGatherRouter.java:135)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at ...
Judging from the top description of the error, I understand the problem to be that Scatter gather does not receive String payloads, even though the current documentation for the component mentions nothing of the sort. Is this correct?
The flow I'm running is fairly simple, receiving a String from an inbound http and trying to route it to a REST service that will use the String to print something (returning text/plain) and to a DB to store the String in a table. Relevant code follows:
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8084" doc:name="HTTP"/>
<expression-filter expression="#[payload != '/favicon.ico']" doc:name="Filter browser icon padding"/>
<logger message="current payload is #[payload]" level="INFO" doc:name="Startup log - to stdout"/>
<scatter-gather doc:name="Scatter-Gather">
<processor-chain>
<logger message="#['Rest branch msg input :' + payload]" level="DEBUG" doc:name="File Logger"/>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8080/application/rest/mensaje?givenName=#[payload]" doc:name="REST Service"/>
<logger message="#['Rest msg output :' + payload]" level="DEBUG" doc:name="File Logger"/>
</processor-chain>
<processor-chain>
<logger message="#['Database msg input :' + payload]" level="DEBUG" doc:name="File Logger"/>
<db:insert config-ref="MySQL_VestaLocal" doc:name="Application Postgress">
<db:parameterized-query><![CDATA[insert into http_user_info (first_name) values ('#[payload]');]]></db:parameterized-query>
</db:insert>
<logger message="#['Database msg output :' + payload]" level="DEBUG" doc:name="File Logger"/>
</processor-chain>
</scatter-gather>
<set-payload value="#['REST DB Success!']" doc:name="Set Payload"/>
Trawling through the net I found this old Mule JIRA issue with an exception similar to what I'm getting, but trying out the suggested solution (workaround?) didn't do anything for me: https://www.mulesoft.org/jira/browse/MULE-7594
Something wrong is happening in your route 0.
You are getting a composite routing exception as per documentation:
The CompositeRoutingException is new to the 3.5.0 Runtime. It extends
the Mule MessagingException to aggregate exceptions from different
routes in the context of a single message router. Exceptions are
correlated to each route through a sequential ID.
This exception exposes two methods which allow you to obtain the IDs
of failed routes and the exceptions returned by each route.
The getExceptions method returns a map where the key is an integer
that identifies the index of the failed route, and the value is the
exception itself. The getExceptionForRouteIndex(int) method returns
the exception of the requested route ID.
As you don't have an execption strategy, the toString is call to that exception and that only prints the route failing (that has nothing to do with the fact that the payload is String)
Please use the following exeption strategy to find out exactly what's wrong:
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger level="ERROR" message="#[exception.exceptions]"/>
</catch-exception-strategy>
I have a requirement of hosting a SOAP web service and hosting a Proxy web service to that main web service...
So I have the following :-
A SOAP web service exposed to perform a CRUD operation.
A Proxy web service to that main web service
Now I have created the SOAP web service which is exposed and perform CRUD operation and it's working fine .. Now the issue is with Proxy web service .. Following is my Proxy web service config :-
<flow name="ProxyFlow" doc:name="ProxyFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8086" path="proxy/mainData" doc:name="HTTP" />
<cxf:proxy-service port="MainDataPort" namespace="http://services.test.com/schema/MainData/V1" service="MainDataService" payload="body" wsdlLocation="MainData.wsdl" doc:name="SOAP"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<jms:outbound-endpoint queue="ProxyQueue" connector-ref="Active_MQ" doc:name="JMS" exchange-pattern="request-response"/>
</flow>
<flow name="ClientProxy" doc:name="ClientProxy">
<jms:inbound-endpoint connector-ref="Active_MQ" address="jms://tcp:ProxyQueue" doc:name="JMS" exchange-pattern="request-response" disableTemporaryReplyToDestinations="true" responseTimeout="90000"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<cxf:proxy-client payload="body" doc:name="SOAP" />
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" method="POST" doc:name="HTTP" />
</flow>
Now as you can see the the proxy web service is using JMS queue .. When I trigger the Proxy web service from SOAPUI ..I get the following exception :-
INFO 2014-09-11 21:16:46,475 [ActiveMQ Session Task-1] org.mule.transport.service.DefaultTransportServiceDescriptor: Loading default outbound transformer: org.mule.transport.jms.transformers.ObjectToJMSMessage
ERROR 2014-09-11 21:16:46,483 [ActiveMQ Session Task-1] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DepthXMLStreamReader (javax.jms.JMSException)
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DepthXMLStreamReader(JMS Code: null) (javax.jms.JMSException)
org.mule.transport.jms.JmsMessageUtils:144 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/JMSException.html)
2. Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DepthXMLStreamReader (javax.jms.JMSException) (org.mule.api.transformer.TransformerException)
org.mule.transport.jms.transformers.AbstractJmsTransformer:79 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
javax.jms.JMSException: Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DepthXMLStreamReader
at org.mule.transport.jms.JmsMessageUtils.toMessage(JmsMessageUtils.java:144)
at org.mule.transport.jms.transformers.AbstractJmsTransformer.transformToMessage(AbstractJmsTransformer.java:66)
at org.mule.transport.jms.transformers.ObjectToJMSMessage.transformMessage(ObjectToJMSMessage.java:54)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR 2014-09-11 21:16:47,522 [ActiveMQ Session Task-2] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : "Message with id "ID:ANIRBAN-PC-49972-1410450386406-1:1:14:1:1" has been redelivered 1 times on endpoint "jms://tcp:ProxyQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. "Message with id "ID:ANIRBAN-PC-49972-1410450386406-1:1:14:1:1" has been redelivered 1 times on endpoint "jms://tcp:ProxyQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage (org.mule.transport.jms.redelivery.MessageRedeliveredException)
org.mule.transport.jms.redelivery.JmsXRedeliveryHandler:81 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/jms/redelivery/MessageRedeliveredException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.transport.jms.redelivery.MessageRedeliveredException: "Message with id "ID:ANIRBAN-PC-49972-1410450386406-1:1:14:1:1" has been redelivered 1 times on endpoint "jms://tcp:ProxyQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage
at org.mule.transport.jms.redelivery.JmsXRedeliveryHandler.handleRedelivery(JmsXRedeliveryHandler.java:81)
at org.mule.transport.jms.MultiConsumerJmsMessageReceiver$JmsWorker.preProcessMessage(MultiConsumerJmsMessageReceiver.java:512)
at org.mule.transport.AbstractReceiverWorker$1$1.process(AbstractReceiverWorker.java:117)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
WARN 2014-09-11 21:16:56,369 [[Dummysimpleclientwebservice].connector.http.mule.default.receiver.03] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://services.vertu.com/schema/MainData/V1}MainDataService has thrown exception, unwinding now
java.lang.NullPointerException
at org.apache.cxf.databinding.stax.StaxDataBinding$XMLStreamDataWriter.write(StaxDataBinding.java:147)
at org.apache.cxf.databinding.stax.StaxDataBinding$XMLStreamDataWriter.write(StaxDataBinding.java:135)
at org.apache.cxf.databinding.stax.StaxDataBinding$XMLStreamDataWriter.write(StaxDataBinding.java:131)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:119)
at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:232)
at org.mule.module.cxf.CxfInboundMessageProcessor$1.write(CxfInboundMessageProcessor.java:426)
at org.mule.transport.http.HttpServerConnection.writeResponse(HttpServerConnection.java:353)
at org.mule.transport.http.HttpMessageProcessTemplate.sendResponseToClient(HttpMessageProcessTemplate.java:137)
at org.mule.execution.FlowProcessingPhase.sendResponseIfNeccessary(FlowProcessingPhase.java:153)
at org.mule.execution.FlowProcessingPhase.access$000(FlowProcessingPhase.java:29)
at org.mule.execution.FlowProcessingPhase$1$1.process(FlowProcessingPhase.java:78)
at org.mule.execution.FlowProcessingPhase$1$1.process(FlowProcessingPhase.java:63)
at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:54)
at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:109)
at org.mule.execution.FlowProcessingPhase$1.run(FlowProcessingPhase.java:62)
at org.mule.transport.TrackingWorkManager$TrackeableWork.run(TrackingWorkManager.java:267)
at org.mule.work.WorkerContext.run(WorkerContext.java:286)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Now I can find that the main webservice is called internally and the Data are created in DB.. But I guess it's unable to transform the response back to the Proxy client .. any suggestion ..
Try using the proxy client in the following way.
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" method="POST" doc:name="HTTP" >
<cxf:proxy-client payload="body" doc:name="SOAP" />
</http:outbound-endpoint>
<logger level="INFO" message="#[message.payloadAs(java.lang.String)]" />
The HTTP outbound is retruning the response in the format of DepthXMLStreamReader. The above format of Proxy-client should help. The logger will read the response from the StreamReader so it is in a serializable format.
Hope this helps.
I realized that the payload after the Http outbound is stream so, it need to be converted into String or else will be getting the exception.
So, the solution that worked me is :-
<logger level="INFO" message="#[message.payloadAs(java.lang.String)]" />
Alternately I realized that putting a <byte-array-to-string-transformer> will also work
I have a requirement in Mule in which I need to expose a SOAP web service ..
Now I am implementing it in 2 flows :-
<flow name="ServiceFlow" doc:name="ServiceFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP" />
<cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData" doc:name="SOAP" />
<object-to-string-transformer doc:name="Object to String"/>
<jms:outbound-endpoint queue="NewQueue" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
<flow name="Flow2" doc:name="Flow2" >
<jms:inbound-endpoint connector-ref="Active_MQ" address="jms://tcp:NewQueue" doc:name="JMS" exchange-pattern="request-response"/>
<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl" >
<method-entry-point-resolver>
<include-entry-point method="retrieveDataOperation"/>
<include-entry-point method="insertDataOperation"/>
<include-entry-point method="updateDataOperation"/>
<include-entry-point method="deleteDataOperation"/>
</method-entry-point-resolver>
</component>
<logger level="INFO" message="payload :-#[message.payload]" doc:name="Logger"/>
</flow>
In the first flow (ServiceFlow) I am trying to send the SOAP request in an ActiveMQ queue and in second flow (Flow2) ..I am trying to consume the request in MainDataImpl class .. But I am getting an exception while consuming the request :-
Exception stack is:
1. "Message with id "ID:ANIRBAN-PC-49419-1407595657591-1:1:6:1:1" has been redelivered 1 times on endpoint "jms://tcp:NewQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage (org.mule.transport.jms.redelivery.MessageRedeliveredException)
org.mule.transport.jms.redelivery.JmsXRedeliveryHandler:81 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/jms/redelivery/MessageRedeliveredException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.transport.jms.redelivery.MessageRedeliveredException: "Message with id "ID:ANIRBAN-PC-49419-1407595657591-1:1:6:1:1" has been redelivered 1 times on endpoint "jms://tcp:NewQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage
at org.mule.transport.jms.redelivery.JmsXRedeliveryHandler.handleRedelivery(JmsXRedeliveryHandler.java:81)
at org.mule.transport.jms.MultiConsumerJmsMessageReceiver$JmsWorker.preProcessMessage(MultiConsumerJmsMessageReceiver.java:512)
at org.mule.transport.AbstractReceiverWorker$1$1.process(AbstractReceiverWorker.java:117)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Now I want to know how can I resolve the issue as I guess MainDataImpl is expecting the message as object type .. but there is no way to convert the String message into Object ... Any solution for the above issue ??? Please Help
UPDATE AFTER ADDING OBJECT TO XML:-
<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="ServiceFlow" doc:name="ServiceFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP" />
<cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData" doc:name="SOAP" />
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
<!-- <vm:outbound-endpoint exchange-pattern="request-response" path="Flow1-WT-Main" doc:name="VM"/> -->
<jms:outbound-endpoint queue="NewQueue" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
<flow name="Flow2" doc:name="Flow2" >
<!-- <vm:inbound-endpoint exchange-pattern="request-response" path="Flow1-WT-Main" doc:name="VM"/> -->
<jms:inbound-endpoint connector-ref="Active_MQ" address="jms://tcp:NewQueue" doc:name="JMS" exchange-pattern="request-response"/>
<mulexml:xml-to-object-transformer doc:name="XML to Object"/>
<async doc:name="Async">
<logger message="Payload :-#[message.payload]" level="INFO" doc:name="Logger"/>
</async>
<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl" >
<method-entry-point-resolver>
<include-entry-point method="retrieveDataOperation"/>
<include-entry-point method="insertDataOperation"/>
<include-entry-point method="updateDataOperation"/>
<include-entry-point method="deleteDataOperation"/>
</method-entry-point-resolver>
</component>
<logger level="INFO" message="ccccccc :-#[message.payload]" doc:name="Logger"/>
</flow>
Now the exception is :-
INFO 2014-08-09 21:10:33,426 [ActiveMQ Session Task-1] org.mule.api.processor.LoggerMessageProcessor: ccccccc :-com.test.services.schema.maindata.v1.DataResponse#1ca5a88a
INFO 2014-08-09 21:10:33,426 [[Dummysimpleclientwebservice].Flow2.1.02] org.mule.api.processor.LoggerMessageProcessor: Payload :-com.test.services.schema.maindata.v1.DataRequest#3fdc0ab7
ERROR 2014-08-09 21:10:33,433 [ActiveMQ Session Task-1] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DataResponse (javax.jms.JMSException)
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DataResponse(JMS Code: null) (javax.jms.JMSException)
org.mule.transport.jms.JmsMessageUtils:144 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/JMSException.html)
2. Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DataResponse (javax.jms.JMSException) (org.mule.api.transformer.TransformerException)
org.mule.transport.jms.transformers.AbstractJmsTransformer:79 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
javax.jms.JMSException: Source was not of a supported type. Valid types are Message, String, Map, InputStream, List, byte[], Serializable or OutputHandler, but was DataResponse
at org.mule.transport.jms.JmsMessageUtils.toMessage(JmsMessageUtils.java:144)
at org.mule.transport.jms.transformers.AbstractJmsTransformer.transformToMessage(AbstractJmsTransformer.java:66)
at org.mule.transport.jms.transformers.ObjectToJMSMessage.transformMessage(ObjectToJMSMessage.java:54)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR 2014-08-09 21:10:34,488 [ActiveMQ Session Task-2] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : "Message with id "ID:ANIRBAN-PC-49768-1407598818233-1:1:6:1:1" has been redelivered 1 times on endpoint "jms://tcp:NewQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. "Message with id "ID:ANIRBAN-PC-49768-1407598818233-1:1:6:1:1" has been redelivered 1 times on endpoint "jms://tcp:NewQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage (org.mule.transport.jms.redelivery.MessageRedeliveredException)
org.mule.transport.jms.redelivery.JmsXRedeliveryHandler:81 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/transport/jms/redelivery/MessageRedeliveredException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.transport.jms.redelivery.MessageRedeliveredException: "Message with id "ID:ANIRBAN-PC-49768-1407598818233-1:1:6:1:1" has been redelivered 1 times on endpoint "jms://tcp:NewQueue", which exceeds the maxRedelivery setting of 0 on the connector "Active_MQ". Message payload is of type: ActiveMQTextMessage
at org.mule.transport.jms.redelivery.JmsXRedeliveryHandler.handleRedelivery(JmsXRedeliveryHandler.java:81)
at org.mule.transport.jms.MultiConsumerJmsMessageReceiver$JmsWorker.preProcessMessage(MultiConsumerJmsMessageReceiver.java:512)
at org.mule.transport.AbstractReceiverWorker$1$1.process(AbstractReceiverWorker.java:117)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
As you guessed it, the problem is that you serialize the inbound message object to a String with object-to-string-transformer and, via a JMS queue, try to feed it to the MainDataImpl object, which takes objects as input parameters for its different operations.
The solution is to simply serialize the inbound object to XML, send it via JMS then deserialize it back to an object.
For this replace the object-to-string-transformer with an object-to-xml-transformer and add a xml-to-object-transformer right after the jms:inbound-endpoint.
EDIT
I didn't realize you're using NewQueue in request-response fashion, because you actually inconsistently declare it. On the jms:outbound-endpoint you do not provide an exchange-pattern which makes it one-way by default ; while on the jms:inbound-endpoint your set the exchange-pattern to request-response, which triggers the execution of the response phase of Flow2.
So: be consistent, use the same exchange-pattern on both JMS endpoints or, even better, declare a global JMS endpoint with the right exchange-pattern and ref-it from the jms:inbound and outbound endpoints.
If you decide to stay with request-response, then you need to do the same for the response, ie. serialize the result of calling MainDataImpl (a DataResponse object) back to XML and in ServiceFlow deserialize it back to object.
So, the working solution is (as per David's suggestion)
1. Need to add <mulexml:object-to-xml-transformer doc:name="Object to XML"/> before JMS outbound and <mulexml:xml-to-object-transformer doc:name="XML to Object"/> after JMS inbound
2. Need to use the same exchange-pattern on both JMS endpoints