I have a problem with setting Connection Timeout on HTTP Request Connector (not to confuse with Response Timeout) with Mule 3.7.
Configuration I'm using is not changing this arbitrary ~5 second delay between initiating connection and throwing "java.net.ConnectException: Connect timeout", even if https://docs.mulesoft.com/mule-user-guide/v/3.7/tcp-transport-reference suggests that setting connectionTimeout attribute should do the trick.
What am I missing? Is there any other way to specify this timeout? Or is this dependent on the OS?
Flow ilustrating the problem:
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:tcp="http://www.mulesoft.org/schema/mule/tcp" xmlns:tls="http://www.mulesoft.org/schema/mule/tls" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" 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"
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/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd
http://www.mulesoft.org/schema/mule/tcp http://www.mulesoft.org/schema/mule/tcp/current/mule-tcp.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<http:request-config name="HTTP_Request_Configuration" host="123.123.123.123" port="4444" doc:name="HTTP Request Configuration" responseTimeout="30000" usePersistentConnections="false" >
<tcp:client-socket-properties connectionTimeout="30000" timeout="30000"/>
</http:request-config>
<flow name="connectionTimeoutTestFlow">
<quartz:inbound-endpoint jobName="Knock" repeatInterval="60000" responseTimeout="100000" doc:name="Quartz">
<quartz:event-generator-job/>
</quartz:inbound-endpoint>
<logger message="Start Request" level="INFO" doc:name="Logger"/>
<http:request config-ref="HTTP_Request_Configuration" path="/debug/index.jsp" method="GET" doc:name="HTTP"/>
</flow>
</mule>
Output:
INFO 2016-02-10 12:53:55,736 [[connectionTimeoutTest].connectionTimeoutTestFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Start Request
ERROR 2016-02-10 12:54:01,321 [[connectionTimeoutTest].connectionTimeoutTestFlow.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Error sending HTTP request. Message payload is of type: NullPayload
Type : org.mule.api.MessagingException
Code : MULE_ERROR--2
Payload : {NullPayload}
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
********************************************************************************
Exception stack is:
1. Connect timeout (java.net.ConnectException)
org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectCompletionHandler:1283 (null)
2. java.net.ConnectException: Connect timeout (java.util.concurrent.ExecutionException)
org.glassfish.grizzly.impl.SafeFutureImpl$Sync:349 (null)
3. java.util.concurrent.ExecutionException: java.net.ConnectException: Connect timeout (java.io.IOException)
org.mule.module.http.internal.request.grizzly.GrizzlyHttpClient:234 (null)
4. Error sending HTTP request. Message payload is of type: NullPayload (org.mule.api.MessagingException)
org.mule.module.http.internal.request.DefaultHttpRequester:287 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
java.net.ConnectException: Connect timeout
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectCompletionHandler.cancelled(SingleEndpointPool.java:1283)
at org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:185)
at org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:277)
at org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerCancel(SafeFutureImpl.java:389)
at org.glassfish.grizzly.impl.SafeFutureImpl.cancel(SafeFutureImpl.java:247)
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1351)
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1343)
at org.glassfish.grizzly.utils.DelayedExecutor$DelayedRunnable.run(DelayedExecutor.java:158)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:744)
********************************************************************************
you can use a global configuration, defined at the top of your .xml, in which you specify Timeout for all your services, in example:
<configuration defaultTransactionTimeout="300000" defaultResponseTimeout="300000" doc:name="Configuration">
<default-threading-profile poolExhaustedAction="RUN"/>
</configuration>
I hope this helps.
Try to increase the http timeout in the http global config, you can do something like below:
<https:connector
name="HTTP_HTTPS"
cookieSpec="netscape"
validateConnections="false"
sendBufferSize="0"
receiveBufferSize="0"
receiveBacklog="0"
clientSoTimeout="1000"
serverSoTimeout="1000"
socketSoLinger="1000"
doc:name="HTTP-HTTPS"
socketMaxWait="1000"
connectionTimeout="1000"
keepAlive="true">
Related
I'm using cache scope and object store to cache data returned from a Salesforce Query using Salesforce Connector.
I've added On error continue to catch any Salesforce Connector exceptions.
If there is an exception in Salesforce Connector (like Salesforce Connectivity), the application throws an exception and executes On error continue block, but when it is called again application hangs at the cache scope and doesn't give any response/error message. Also, On error continue block is executed thrice when the application is executed first time.
It's running fine in debug mode.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:os="http://www.mulesoft.org/schema/mule/os" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:salesforce="http://www.mulesoft.org/schema/mule/salesforce"
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:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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/salesforce http://www.mulesoft.org/schema/mule/salesforce/current/mule-salesforce.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/os http://www.mulesoft.org/schema/mule/os/current/mule-os.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="6a5b02b3-836d-43b5-9dbe-41719d20258f" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<salesforce:sfdc-config name="Salesforce_Config" doc:name="Salesforce Config" doc:id="3facafa3-5d07-4717-901a-487f0cdeabb2" >
<salesforce:basic-connection username="..." password="..." securityToken="..." url="https://login.salesforce.com/services/Soap/u/48.0" />
</salesforce:sfdc-config>
<ee:object-store-caching-strategy name="Caching_Strategy" doc:name="Caching Strategy" doc:id="4ebcc02a-3c51-445b-bee5-0c95e4ce6e01" keyGenerationExpression="#['1']" >
<os:private-object-store persistent="false" maxEntries="1" entryTtl="1" />
</ee:object-store-caching-strategy>
<flow name="test-errorFlow" doc:id="49520788-7379-45cb-9276-cdb6b268398c" >
<http:listener doc:name="Listener" doc:id="ce5faf93-3153-4f93-8313-90d465f920c6" config-ref="HTTP_Listener_config" path="/test" allowedMethods="GET">
<http:response statusCode="#[vars.httpStatus]" />
<http:error-response statusCode="#[vars.httpStatus]" >
<http:body ><![CDATA[#[error]]]></http:body>
</http:error-response>
</http:listener>
<ee:cache doc:name="Cache" doc:id="ae4e7d76-0f98-4202-9a51-59373ea3ee1c" cachingStrategy-ref="Caching_Strategy">
<salesforce:query doc:name="Query" doc:id="1498398a-7b1f-4a27-aff8-3991d4e9cbca" config-ref="Salesforce_Config">
<salesforce:salesforce-query><![CDATA[Select Id, Name from Account]]></salesforce:salesforce-query>
</salesforce:query>
</ee:cache>
<ee:transform doc:name="Transform Message" doc:id="f864be76-86a9-4726-b1f1-586ffeabb0db" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<error-handler >
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="038cd795-2174-4d9a-b759-2921dd12a64e" type="ANY">
<logger level="INFO" doc:name="Logger" doc:id="186587c2-0beb-416a-b589-7239a2cba7dd" message="#[error]"/>
</on-error-continue>
</error-handler>
</flow>
</mule>
'On error continue' means to finish flow even if error occurs. But finishing flow does not mean that it did its job - in particular cache value was not obtained. That's the reason the erst is failing.
Rearrange your flow - if cache value is null - run cache again and again ( for example https://docs.mulesoft.com/mule-runtime/4.3/until-successful-scope ) and only success continue your regular flow with existing real cache value.
The problem is likely that there is nothing to cache, because the error aborted the execution.
You can either use a Try scope to handle the error inside the Cache scope, or call to another flow with a flow-ref, and handle the error inside that other flow.
Example:
<ee:cache doc:name="Cache" cachingStrategy-ref="Caching_Strategy">
<try>
<salesforce:query doc:name="Query" config-ref="Salesforce_Config">
<salesforce:salesforce-query><![CDATA[Select Id, Name from Account]]></salesforce:salesforce-query>
</salesforce:query>
<error-handler>
<on-error-continue>
....
</on-error-continue>
</error-handler>
</try>
</ee:cache>
My Mulesoft POC contains globalErrorHandler as well as localErrorHandler having OnErrorContinue scope, I noticed yet it throws a MULE:EXPRESSION error ,Can anyone let me know the reason for it . The code is below enclosed with the pic of the flow .
Code
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
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:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.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="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="f8f3f4bb-341a-43ec-acf8-9ed33419f5ef" basePath="/error" >
<http:listener-connection host="0.0.0.0" port="8082" />
</http:listener-config>
<configuration doc:name="Configuration" doc:id="689a9085-287e-43e4-8e3d-5eeac857dc64" defaultErrorHandler-ref="globalError_Handler"/>
<flow name="example-errorFlow" doc:id="c37abd41-2143-4da1-848a-a8c240853b60" >
<http:listener doc:name="Listener" doc:id="9cda3f2d-a48d-40bd-96a4-54d856d0438e" config-ref="HTTP_Listener_config" path="/"/>
<set-payload value='"MAIN"' doc:name="Set Payload" doc:id="a1b3890f-6157-4716-84d3-8f6ccd6e9af5" />
<ee:transform doc:name="Transform Message" doc:id="9fc2571b-7038-4359-82db-be624d48b343" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
["RESPONSE"] ++ payload ]]></ee:set-payload>
</ee:message>
</ee:transform>
<error-handler >
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" type= "HTTP:NOT_FOUND" doc:id="e6f2b028-e3ca-4eff-b878-0f41dd53d693" >
<set-payload value='"HTTP:NOT_FOUND"' doc:name='"HTTP:NOT_FOUND"' doc:id="c465edf3-bbac-4fca-bfb1-f2a6678e1173" />
</on-error-continue>
</error-handler>
</flow>
<error-handler name="globalError_Handler" doc:id="05e153b7-d663-4aa1-85c0-8fefbf76c39b" >
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="c0e80820-db0f-4b3f-b0e2-c74c47e3a5e7" >
<set-payload value="global Error Handler" doc:name="global Error Handler" doc:id="0055b184-4dd6-4d20-8284-27534570f723" />
</on-error-continue>
</error-handler>
</mule>
FlowImage
The error is coming from your Transform component but you are handling only HTTP:NOT FOUND error.
Handle all exceptions as described here
https://simpleflatservice.com/mule4/OnErrorContinue.html
In particular - simple remove error type and you will see actual message and can fix it.
Post it here and we can help.
In the transform you're trying to use ++ function with an Array and String which is incorrect (in your case its ["RESPONSE"] ++ payload where payload = "MAIN"), coming to flow error handling you're handling a specific error from HTTP namespace, whereas the error you get is from MULE namespace of type EXPRESSION, so thats the reason the local error handler is unable to handle that error.
To handle this either use MULE:EXPRESSION or MULE:ANY which can serve as a parent error type for MULE:EXPRSSION and HTTP:NOT_FOUND errors
The MULE namespace is an implicit namespace you can also call it as a parent namespace which can handle any runtime based error.
To better understand errors, their hierarchy and global error handler consider visiting the resource mentioned below.
https://youtu.be/9WcG9teCrvo
Hi I'm playing around with a SOAP request, I am having trouble with the cxf proxy client. I'm basically sending a soap request to the http endpoint, removing the SOAP envelope, then trying to add it back it back on with the proxy client.
I'm expecting to get an unathorized response (as I'm removing the wsse headers).
However, I get the following soap response: "Response code 500 mapped as failure. Message payload is of type: BufferInputStream"
and the console logs the following (Note this is only the start of it)
WARN 2015-05-13 12:38:28,886 [[sandbox2].HTTP_Listener_Configuration.worker.01] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://support.cxf.module.mule.org/}ProxyService#{http://support.cxf.module.mule.org/}invoke has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Response code 500 mapped as failure. Message payload is of type: BufferInputStream
at org.mule.module.cxf.transport.MuleUniversalConduit$2.handleMessage(MuleUniversalConduit.java:194) ~[mule-module-cxf-3.6.1.jar:3.6.1]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) ~[cxf-api-2.5.9.jar:2.5.9]
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531) ~[cxf-rt-core-2.5.9.jar:2.5.9]
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:462) ~[cxf-rt-core-2.5.9.jar:2.5.9]
Here is my flow
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" 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.1"
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/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8086" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="localhost" port="8080" basePath="my-app/RetrieveAct.svc" doc:name="HTTP Request Configuration"/>
<flow name="myFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<logger message="message received #[payload] " level="INFO" doc:name="Logger"/>
<cxf:proxy-service namespace="PfPolicyService" payload="body" doc:name="CXF"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<cxf:proxy-client payload="body" doc:name="CXF"/>
<response>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</response>
<http:request config-ref="HTTP_Request_Configuration1" path="http://localhost:8080/my-app/RetrieveAct.svc" method="POST" doc:name="HTTP">
<http:request-builder>
<http:header headerName="soapAction" value="getUserAcct"/>
</http:request-builder>
</http:request>
</flow>
</mule>
Can anyone explain what I am doing wrong and how to correct the issue?
Thanks
The issue you're experiencing is because your modification of the SOAP request is ending up as an invalid SOAP request, therefore the server cannot parse it and it is returning a 500 http status code.
You can use CXF's logging interceptors to be able to inspect the final result of what you're sending.
Your mule flow seems okey to me, the proxied service might blow up for all sorts of reasons.
Add logging interceptors to the proxy client and see whether this enables you to pinpoint the issue:
<cxf:proxy-client payload="body">
<cxf:inInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor">
<spring:property name="prettyLogging" value="true" />
</spring:bean>
</cxf:inInterceptors>
<cxf:outInterceptors>
<spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor">
<spring:property name="prettyLogging" value="true" />
</spring:bean>
</cxf:outInterceptors>
</cxf:proxy-client>
Or alternatively, use TPCMon to capture network traffic.
Setting up a service mock and proper test case first would be a good sanity check, before doing integration testing.
I am having trouble starting a Mule application from MuleStudio. Any pointers?
Here is my Configuration xml :
<?xml version="1.0" encoding="UTF-8"?>
<mule 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="CE-3.4.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">
<flow name="testFlow1" doc:name="testFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<logger message="testing" level="INFO" doc:name="Logger"/>
</flow>
</mule>
.... here is the exception I am getting
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Initializing app 'test' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2014-05-25 16:48:56,694 [main] org.mule.module.launcher.application.DefaultMuleApplication: App 'test' never started, nothing to dispose of
Exception in thread "main" org.mule.module.launcher.DeploymentException: Failed to deploy application [test]
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:61)
at org.mule.tooling.server.application.ApplicationDeployer.run(ApplicationDeployer.java:58)
at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:91)
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
at org.mule.config.DefaultMuleConfiguration.validateXML(DefaultMuleConfiguration.java:371)
at org.mule.config.DefaultMuleConfiguration.<init>(DefaultMuleConfiguration.java:209)
at org.mule.module.launcher.ApplicationMuleContextBuilder.createMuleConfiguration(ApplicationMuleContextBuilder.java:36)
at org.mule.context.DefaultMuleContextBuilder.getMuleConfiguration(DefaultMuleContextBuilder.java:135)
at org.mule.context.DefaultMuleContextBuilder.buildMuleContext(DefaultMuleContextBuilder.java:97)
at org.mule.context.DefaultMuleContextFactory.buildMuleContext(DefaultMuleContextFactory.java:215)
at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:201)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:79)
at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:207)
at org.mule.module.launcher.application.ApplicationWrapper.init(ApplicationWrapper.java:64)
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:47)
... 2 more
I am trying to develop a mule flow which takes a xml in the form of a string from a JMS queue and converts it into a POJO. I am using JAXB annotations to define the mappings between the xml and the class attributes. Below is the sample xml that is received on the JMS queue as a string.
<FCUBS_NOTIFICATION xmlns="http://fcubs.ofss.com/notify/NOTIF_UP_TRANSACTION">
<FCUBS_NOTIF_HEADER>
<MSGID>9132820000357947</MSGID>
</FCUBS_NOTIF_HEADER>
</FCUBS_NOTIFICATION>
My POJO class is as below:
package com.bean;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
#XmlRootElement(name="FCUBS_NOTIFICATION")
public class Notification {
private String MSGID;
public String getMSGID() {
return MSGID;
}
#XmlElement(name="MSGID")
public void setMSGID(String mSGID) {
MSGID = mSGID;
}
}
I have a jaxb.index file in the com.bean package consisting of only one bean
Notification
My mule flow config file is as below:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" 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.4.1" 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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd">
<spring:beans>
<spring:bean name="myJaxb" class="javax.xml.bind.JAXBContext" factory-method="newInstance">
<!-- colon-separated (:) list of package names where JAXB classes exist -->
<spring:constructor-arg value="com.bean"/>
</spring:bean>
</spring:beans>
<jms:activemq-connector name="Active_MQ" specification="1.1" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="JMS-exampleFlow1" doc:name="JMS-exampleFlow1">
<jms:inbound-endpoint queue="NotificationQueue" connector-ref="Active_MQ" doc:name="JMS"/>
<logger message="Payload after picking message from queue is #[message.payload]" level="INFO" doc:name="Logger"/>
<mulexml:xml-to-object-transformer returnClass="com.bean.Notification" doc:name="XML to Object"/>
<logger level="INFO" doc:name="Logger" message="Payload after xml to object transformation is #[message.payload]"/>
</flow>
</mule>
I am using Mule Studio for development and below is the error I get -
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'jms-example' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2013-11-27 16:19:44,225 [[jms-example].JMS-exampleFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Payload after picking message from queue is <FCUBS_NOTIFICATION xmlns="http://fcubs.ofss.com/notify/NOTIF_UP_TRANSACTION"><FCUBS_NOTIF_HEADER><MSGID>9132820000357947</MSGID></FCUBS_NOTIF_HEADER></FCUBS_NOTIFICATION>
ERROR 2013-11-27 16:19:44,227 [[jms-example].JMS-exampleFlow1.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : FCUBS_NOTIFICATION (com.thoughtworks.xstream.mapper.CannotResolveClassException). Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. FCUBS_NOTIFICATION (com.thoughtworks.xstream.mapper.CannotResolveClassException)
com.thoughtworks.xstream.mapper.DefaultMapper:56 (null)
2. FCUBS_NOTIFICATION (com.thoughtworks.xstream.mapper.CannotResolveClassException). Message payload is of type: String (org.mule.api.transformer.TransformerMessagingException)
org.mule.transformer.AbstractTransformer:139 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerMessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
com.thoughtworks.xstream.mapper.CannotResolveClassException: FCUBS_NOTIFICATION
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:56)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Is there anything I am missing here ?
Thanks in advance.
The serialization/deserialization in the xml-to-object-transformer is done through XStream, so JAXB won't matter at that point.
You would need an alias:
<mulexml:xml-to-object-transformer returnClass="com.bean.Notification" doc:name="XML to Object">
<mulexml:alias name="FCUBS_NOTIFICATION" class="com.bean.Notification"/>
</mulexml:xml-to-object-transformer>