couldn't get data while connecting mule with linkedin - mule

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

Related

MULE BOX Connector - Unable to fetch access token. Message payload is of type: NullPayload

I am using Mule 3.7.3 . Below is the Flow -
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8080" doc:name="HTTP Listener Configuration"/>
<box:config name="Box" clientId="05zpeboxxfms6fo7805izrxff9dwbc74" clientSecret="LVD5juoF7ookFVn4uN69Pco3NI4EQeE0" doc:name="Box">
<box:oauth-callback-config domain="localhost" localPort="8080" remotePort="8080" path="callback"/>
</box:config>
<flow name="boxAuthenticationFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/auth" doc:name="HTTP"/>
<box:authorize config-ref="Box" doc:name="Box-Authorize" accessTokenId="FgL53vlbdYMaXDMykVzS8z7CKz8QsZ0J"/>
<box:create-folder config-ref="Box" folderName="test folder" doc:name="Box"/>
</flow>
But I am getting below error after i select Authorize. ..
Message : Unable to fetch access token. Message payload is of type: NullPayload
Type : org.mule.api.MessagingException
Code : MULE_ERROR--2
Payload : {NullPayload}
JavaDoc :
Exception stack is:
1. Connection timed out: connect (java.net.ConnectException)
java.net.TwoStacksPlainSocketImpl:-2 (null)
2. Error found while consuming http resource at https://www.box.com/api/oauth2/token (java.lang.RuntimeException)
org.mule.security.oauth.util.HttpUtilImpl:93 (null)
3. Unable to fetch access token. Message payload is of type: NullPayload (org.mule.api.MessagingException)
org.mule.security.oauth.processor.OAuth2FetchAccessTokenMessageProcessor:95
Tried a lot but no change in behavior need helps please ..
Try the following code
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<box:config name="Box" clientId="05zpeboxxfms6fo7805izrxff9dwbc74" clientSecret="LVD5juoF7ookFVn4uN69Pco3NI4EQeE0" doc:name="Box">
<box:oauth-callback-config domain="localhost" localPort="8082" remotePort="8082" path="callback" />
</box:config>
<objectstore:config name="ObjectStore" objectStore-ref="_defaultInMemoryObjectStore" doc:name="ObjectStore: Configuration" />
<flow name="boxAuthenticationFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/auth" doc:name="HTTP"/>
<box:authorize config-ref="Box" doc:name="Box-Authorize" />
<set-payload value="#[flowVars._oauthVerifier]" doc:name="Set Payload"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<box:create-folder config-ref="Box" folderName="test folder" doc:name="Box"/>
</flow>
It's an working code. All the best.
http://thirumal-opensource.blogspot.in/2016/05/how-to-get-authentication-from-box.html

Unable to fetch access token from box or dropbox using mulesoft connector

I tried to run the box connector after importing the project from github https://github.com/mulesoft/box-connector
project running successfully but after grant permission, I am getting the following error,
Unable to fetch access token. Message payload is of type: NullPayload
Console Error:
ERROR 2015-10-05 13:36:28,731 [[doc-sample].auto-generated-listener-config-0.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy:
Message : Unable to fetch access token. Message payload is of type: NullPayload
Type : org.mule.api.MessagingException
Code : MULE_ERROR--2
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
Payload : {NullPayload}
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.util.store.PartitionedPersistentObjectStore:105 (null)
2. Unable to fetch access token. Message payload is of type: NullPayload (org.mule.api.MessagingException)
Its working for me without issues. Anyway below is the my working POC code XML. Give a try with this and note that I am using Mule 3.5.2 run time version
<box:config name="Box_Global_Connector" clientId="*********"
clientSecret="********" doc:name="Box">
<box:oauth-callback-config domain="localhost"
localPort="8083" path="callback" remotePort="8083" />
</box:config>
<flow name="mule_box_authorize" doc:name="mule_box_authorize">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8082" path="createFolder" doc:name="HTTP" />
<logger message="---- Box authorize service triggred" level="INFO"
doc:name="Logger" />
<box:authorize config-ref="Box_Global_Connector"
doc:name="Box_Authorize" />
<box:create-folder config-ref="Box_Global_Connector"
folderName="Sample_Folder_07Oct2015_v2" doc:name="Box_CreateFolder" />
</flow>
Recently I did a POC on Integrating Mule ESB with Box using Mule Box Connector and made a PPT on this. Just go through the below slidshare PPT for more details
http://www.slideshare.net/RamakrishnaNarkedami/mule-integration-with-box
Also Share your mule config XML code to see where is the issue.
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="cookbook-helloworldFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<component class="com.enkindle.Greeting" doc:name="Java"/>
</flow>
The below code will work fine with version 3.7.2
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<box:config name="Box" clientId="05zpeboxxfms6fo7805izrxff9dwbc74" clientSecret="LVD5juoF7ookFVn4uN69Pco3NI4EQeE0" doc:name="Box">
<box:oauth-callback-config domain="localhost" localPort="8082" remotePort="8082" path="callback"/>
</box:config>
<objectstore:config name="ObjectStore__Configuration" objectStore-ref="_defaultInMemoryObjectStore" doc:name="ObjectStore: Configuration" />
<flow name="boxAuthenticationFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/auth" doc:name="HTTP"/>
<box:authorize config-ref="Box" doc:name="Box-Authorize" />
</flow>

How to get HTTP status code for REST service in Mule

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>

How to get the SOAP request from an ActiveMQ queue and implement it in the webservice

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

Mule: transform the results of outbound-endpoint

The following flow transforms incoming an JSON payload into a SOAP message which is used in a subflow to make a webservice request. Everything works fine -- i'm able to send a response back for the original (incoming) request, but I want to add a final step to transform the SOAP result into JSON before sending it back to the client.
Here is the flow:
<mule ...>
<data-mapper:config name="json2xml_grf" transformationGraphPath="json2xml.grf" doc:name="DataMapper"/>
<flow name="simpleFlow" doc:name="simpleFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<set-property propertyName="Access-Control-Allow-Origin" value="*" doc:name="Property"/>
<choice doc:name="Choice">
<when expression="#[message.inboundProperties['http.method'] != 'OPTIONS']">
<data-mapper:transform config-ref="json2xml_grf" doc:name="DataMapper"/>
<flow-ref name="invokeCalculatorService" doc:name="invokeCalculator"/>
</when>
<otherwise>
<http:response-builder status="200" doc:name="HTTP Response Builder">
...
</http:response-builder>
</otherwise>
</choice>
</flow>
<flow name="invokeService" doc:name="invokeService">
<cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="Proxy Client">
</cxf:proxy-client>
<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="/Users/jsleeuw/MuleStudio/workspace/calc/src/main/resources/transformsoap.xslt" doc:name="XSLT"/>
<http:outbound-endpoint exchange-pattern="request-response" doc:name="CalculatorService" method="POST" host="service-host" port="30001"/>
</flow>
</mule>
Putting a DataMapper at the end of the subflow like this:
...
<flow-ref name="invokeCalculatorService" doc:name="invokeCalculator"/>
<data-mapper:transform config-ref="xml2json_grf" doc:name="DataMapper"/>
...
Results in this error:
********************************************************************************
Message : Error executing graph: ERROR (com.mulesoft.mule.module.datamapper.api.exception.DataMapperExecutionException). Message payload is of type: DepthXMLStreamReader
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Content is not allowed in prolog. (org.xml.sax.SAXParseException)
org.apache.xerces.util.ErrorHandlerWrapper:-1 (null)
2. org.xml.sax.SAXParseException: Content is not allowed in prolog. (net.sf.saxon.trans.DynamicError)
net.sf.saxon.event.Sender:308 (null)
3. XPath evaluation failed (org.jetel.exception.JetelRuntimeException)
org.jetel.component.tree.reader.xml.XmlXPathEvaluator:81 (null)
4. Error executing graph: ERROR (com.mulesoft.mule.module.datamapper.api.exception.DataMapperExecutionException)
com.mulesoft.mule.module.datamapper.impl.DefaultGraphExecutor:83 (null)
5. Error executing graph: ERROR (com.mulesoft.mule.module.datamapper.api.exception.DataMapperExecutionException). Message payload is of type: DepthXMLStreamReader (com.mulesoft.mule.module.datamapper.processors.DataMapperMessageExecutionException)
com.mulesoft.mule.module.datamapper.processors.DataMapperMessageProcessor:135 (null)
--------------------------------------------------------------------------------
Whereas putting the datamapper at the end of the subflow ends up blocking the response.
How should I go about transforming my response?
From the Content is not allowed in prolog exception it seems that <flow-ref name="invokeCalculatorService" /> doesn't return a payload that is parseable as XML.
This sub-flow returns a org.apache.cxf.staxutils.DepthXMLStreamReader, which is an javax.xml.stream.XMLStreamReader. The only transformer I know of that can deserialize this type to an XML string is: <mulexml:dom-to-xml-transformer />.
Can you add one just before the data-mapper element?