I am trying to create a simple route in camel,receiving the message from rest uri and storing the message in the cache,I have done the below
my routes are as below
<camel:endpoint id="fooCache1" uri="cache:TestCache1"/> <camel:from uri="cxfrs://bean://rsServer" />
<camel:to uri="log:output?showAll=true" />
<camel:to uri="bean:payProcessor" />
<camel:to uri="direct:start" />
</camel:route>
<camel:route>
<camel:from uri="direct:start" />
<camel:setHeader headerName="CamelCacheOperation">
<camel:constant>CamelCacheAdd</camel:constant>
</camel:setHeader>
<camel:setHeader headerName="CamelCacheKey">
<camel:constant>myCache</camel:constant>
</camel:setHeader>
<camel:to ref="fooCache1"/>
<camel:to uri="log:output?showAll=true" />
</camel:route>
when trying to run it on camel by mvn camel:run I am getting the below error
Error occurred while running main from: org.apache.camel.spring.Main
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:440)
at java.lang.Thread.run(Thread.java:724)
Caused by: org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCrea
teRouteException: Failed to create route route2 at: >>> To[ref:fooCache1] <<< in
route: Route[[From[direct:start]] -> [SetHeader[CamelCacheOperation... because
of org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'fooCache1': FactoryBean threw exception on object creation; nested ex
ception is java.lang.NoSuchMethodError: org.apache.camel.util.ObjectHelper.notNu
ll(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHe
lper.java:1271)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringC
amelContext.java:120)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(Ca
melContextFactoryBean.java:280)
at org.springframework.context.event.SimpleApplicationEventMulticaster.m
ulticastEvent(SimpleApplicationEventMulticaster.java:97)
at org.springframework.context.support.AbstractApplicationContext.publis
hEvent(AbstractApplicationContext.java:303).....
Can someone please let me know where I am wrong and why the cache bean is not being created..I am at loss with this error.
Thanks in advance.
Check the versions of camel-spring and camel-core components, there seems to be a compatibility issue in your case. Use the same version of both the libraries.
After changing the camel version to 2.12.1 its now working properly..
Related
Dynamic population of url in http:outbound-gateway giving error
tried below code
<int:header-enricher input-channel="jmsInboundChannel_POST" output-channel="outbound_gateway_channel_POST">
<int:header name="postURL" expression="payload.getUrl()"/>
<int:header name="Accept-Language" value="en_GB"/>
<int:header name="X-Source-CountryCode" value="GB"/>
<int:header name="X-Source-Operator" value="Enterprise"/>
<int:header name="X-Source-Division" value="OrderManagement"/>
<int:header name="X-Source-System" value="${sapwebservices.http.header.source.system}"/>
<int:header name="X-Source-Timestamp" expression="new java.text.SimpleDateFormat('yyyy-MM-dd HH:mm:ss').format(new java.util.Date())"/>
<int:header name="Accept" value="application/json"/>
<int:header name="Content-Type" value="application/json;charset=UTF-8"/>
</int:header-enricher>
<int:object-to-json-transformer input-channel="outbound_gateway_channel_POST"
output-channel="create_order_outbound_gateway_with_json_POST"
object-mapper="nonNullObjectMapper"/>
<http:outbound-gateway
mapped-request-headers="Accept*, Content-Type, X-*, HTTP_REQUEST_HEADERS"
request-channel="create_order_outbound_gateway_with_json_POST"
reply-channel="print_payload"
url="${UrlVariable}"
http-method="POST"
expected-response-type="java.lang.String"
charset="UTF-8"
request-factory="httpRequestFactory">
<http:uri-variable name="UrlVariable" expression="headers['postURL']"/>
</http:outbound-gateway>
giving error
org.springframework.beans.FatalBeanException: Context hybris Global Context Factory couldn't be created correctly due to, Invalid bean definition with name 'org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler#1' defined in null: Could not resolve placeholder 'UrlVariable' in string value "${UrlVariable}"
I'm using spring-integration-http-2.1 jar.
Trying to dynamically populate the url for every request.
#Gary, tried your solution, getting below exception.
WARN [org.springframework.jms.listener.DefaultMessageListenerContainer#0-6] [GatewayProxyFactoryBean$MethodInvocationGateway] failure occurred in gateway sendAndReceive
org.springframework.integration.MessageHandlingException: HTTP request execution failed for URI [{urlVariable}]
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:284)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:97)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:114)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:101)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:61)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
......
......
......
at org.springframework.jms.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:463)
at org.springframework.jms.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:355)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1069)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1061)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:958)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
at org.apache.http.impl.conn.BasicClientConnectionManager.getConnection(BasicClientConnectionManager.java:162)
at org.apache.http.impl.conn.BasicClientConnectionManager$1.getConnection(BasicClientConnectionManager.java:139)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:456)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
... 86 more
url="${UrlVariable}"
Remove the $; placeholders here are just {....}.
${...} placeholders are evaluated once, during context initialization.
Iam facing an issue while deploying a camel cxf webservice in Jboss Fuse 6.3.
The component is working fine in local instance but it is failing in other instance. It is going in a recursive loop and the logs are piling up with same exception.
Apache camel version - 2.17.0
Jboss EAP 6.4
Any help appreciated.
Endpoint configuration:
<cxf:cxfEndpoint id="ApiReadEndpoint" xmlns:nms="urn:company:esb:services:CoreInsuranceRead:v01"
address="{{esb.api.outread.contextpathurl}}"
wsdlURL="wsdl/aoiRead/CoreInsuranceReadInterface.wsdl"
endpointName="nms:SysTest"
serviceName="nms:CoreInsuranceReadService">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
<entry key="ws-security.validate.token" value="false" />
</cxf:properties>
<cxf:inInterceptors>
<ref bean="wss4jInInterceptor" />
<ref bean="authenticationInterceptor" />
<ref bean="authorizationInterceptor" />
</cxf:inInterceptors>
</cxf:cxfEndpoint>
Camel Route:
<route id="APIReadServiceRoute" streamCache="true">
<from id="ApiReadEndpoint" uri="cxf:bean:ApiReadEndpoint"/>
<doTry id="_doTry1">
<to id="_to1" uri="direct:ClaimRead"/>
<doCatch id="_doCatch1">
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
</doCatch>
</doTry>
</route>
Error logs:
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: cxf://bean:ApiReadEndpoint due to: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'ApiReadEndpoint': FactoryBean threw exception on object creation; nested exception is org.apache.camel.ResolveEndpointFailedException:
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:589) [camel-core-2.17.0.redhat-630310.jar:2.17.0.redhat-630310]
at org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.getObject(AbstractCamelEndpointFactoryBean.java:55)
at org.apache.camel.spring.CamelEndpointFactoryBean.getObject(CamelEndpointFactoryBean.java:60) [camel-spring-2.17.0.redhat-630310.jar:2.17.0.redhat-630310]
at org.apache.camel.spring.CamelEndpointFactoryBean.getObject(CamelEndpointFactoryBean.java:38) [camel-spring-2.17.0.redhat-630310.jar:2.17.0.redhat-630310]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:166) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1467) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) [spring-beans-3.2.18.RELEASE.jar:3.2.18.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1131) [spring-context-3.2.18.RELEASE.jar:3.2.18.RELEASE]
at org.apache.camel.spring.spi.ApplicationContextRegistry.lookupByNameAndType(ApplicationContextRegistry.java:47) [camel-spring-2.17.0.redhat-630310.jar:2.17.0.redhat-630310]
at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookupByNameAndType(PropertyPlaceholderDelegateRegistry.java:63) [camel-core-2.17.0.redhat-630310.jar:2.17.0.redhat-630310]
at org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:137) [camel-core-2.17.0.redhat-630310.jar:2.17.0.redhat-630310]
at org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:157) [camel-core-2.17.0.redhat-630310.jar:2.17.0.redhat-630310]
This question was solved in comments. Issue was in identical assigned id ApiReadEndpoint for consumer and endpoint. This caused recursive endpoint initialization. After renaming or removing optional id attribute from consumer, the context started as expected.
I am using Spring-Integration for my project. I am experimenting with reading of the property/constant values from xml file (instead of .properties file).My xml file in which the properties/constants are placed is as below:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<persistence>
<dataSourceName>CS/PowerSTEPP_CSSTEPPQA</dataSourceName>
</persistence>
<customerservice>
<headerNames>
<jobName>jobDesignerJobName</jobName>
</headerNames>
<headerNames>
<originalPayload>originalPayload</originalPayload>
</headerNames>
<headerNames>
<originalPayloadDuplicate>originalPayload</originalPayloadDuplicate>
</headerNames>
<headerNames>
<legacySystem>legacySystem</legacySystem>
</headerNames>
<headerNames>
<businessArea>businessArea</businessArea>
</headerNames>
<routing>
<jobChannel>headers.jobDesignerJobName+'-InputChannel'</jobChannel>
</routing>
<routing>
<jobErrorChannel>headers.jobDesignerJobName+'-XsltTransformInputChannel'</jobErrorChannel>
</routing>
<legacySystem>
<powerstepp>PowerSTEPP</powerstepp>
</legacySystem>
<PQProviderSearch>
<storedProcedureName>PQPRVSCH</storedProcedureName>
</PQProviderSearch>
<PQProviderSearch>
<ROWREQ>00001</ROWREQ>
</PQProviderSearch>
<PQProviderSearch>
<DBGFLG>Y</DBGFLG>
</PQProviderSearch>
<PQProviderSearch>
<SECDAT></SECDAT>
</PQProviderSearch>
<stylesheet>
<PQProviderSearch>classpath:/CustomerServiceRD/spring-integration/stylesheets/PQProviderSearch.xsl</PQProviderSearch>
</stylesheet>
<stylesheet>
<PQProviderSearchCount>classpath:/CustomerServiceRD/spring-integration/stylesheets/PQProviderSearchCount.xsl</PQProviderSearchCount>
</stylesheet>
<resultSet>
<legacySystem>system</legacySystem>
</resultSet>
<resultSet>
<rootNode>results</rootNode>
</resultSet>
<responseXml>
<soapTemplate>CustomerServiceRD/JobDesigner-responseTemplate.xml</soapTemplate>
</responseXml>
<responseXml>
<xmlBodyTag>//PQ</xmlBodyTag>
</responseXml>
<http>
<header>
<ressponseXml>
<contentType>
<value>CustomerServiceRD/JobDesigner-responseTemplate.xml</value>
</contentType>
</ressponseXml>
</header>
</http>
<http>
<header>
<contentType>
<value>CustomerServiceRD/JobDesigner-responseTemplate.xml</value>
</contentType>
</header>
</http>
<error>
<Fault>Fault</Fault>
</error>
<error>
<errorCode>1111</errorCode>
</error>
<headerNames>
<hostAddress>hostAddress</hostAddress>
</headerNames>
<headerNames>
<hostPort>hostPort</hostPort>
</headerNames>
<error>
<Fault>faultcode</Fault>
</error>
<error>
<faultstring>faultstring</faultstring>
</error>
<error>
<faultactor>faultactor</faultactor>
</error>
<error>
<detail>detail</detail>
</error>
<label>
<externalSystem>ExternalSystem</externalSystem>
</label>
</customerservice>
</config>
Now, I am trying to read the above values in spring integration configuration files as below:
<beans
<import resource="spring-integration/Jobs/*.xml"/>
<!-- map of namespace prefix to URI -->
<util:map id="xmlMessageNamespace">
<entry key="SOAP" value="http://schemas.xmlsoap.org/soap/envelope/" />
</util:map>
<int:channel id="jobDesignerInputChannel" />
<int:channel id="cs-exceptionHandlingChannel" />
<bean id="msgHandler" class="com.dsths.cs.awd.jobs.PQMessageHandler" />
<!-- TODO: Following lines are commented out as part of POC.-->
<!--<bean id="xmlAggregator" class="com.dsths.cs.awd.jobs.XmlAggregator" />
<bean id="httpOutboundGatewayHandler" class="com.dsths.cs.awd.jobs.HttpOutboundGatewayHandler" />
<!--<bean id="xmlFilter" class="com.dsths.cs.awd.jobs.XmlFilter" />-->
<int:chain input-channel="jobDesignerInputChannel" >
<int-xml:xpath-header-enricher default-overwrite="true" should-skip-nulls="true" >
<int-xml:header name="${customerservice.headerNames.legacySystem}" xpath-expression="//LegacySystem" evaluation-type="STRING_RESULT" overwrite="true" />
</int-xml:xpath-header-enricher>
<!-- Some of the AWD jobs contain Business Area info under <code> tag, we should not keep that business area info in the
header since it is not required.This will help us in identifying AWD and Non-AWD jobs-->
<int:header-enricher>
<int:header name="${customerservice.headerNames.businessArea}" expression="#xpath(payload, '//businessArea/Code', 'boolean') ? null : #xpath(payload, '//businessArea')"/>
</int:header-enricher>
<int:router expression="${customerservice.routing.jobChannel}"/>
</int:chain>
<int:chain input-channel="cs-exceptionHandlingChannel">
<!-- Service Activator to handle the errors -->
<int:service-activator ref="msgHandler" method="handleError" />
<!-- Router to routing the error messages to appropriate job channel for xsl transormation -->
<int:router expression="${customerservice.routing.jobErrorChannel}"/>
</int:chain>
</beans>
But, unfortunately I am getting the following exception when try to read the properties from the xml file:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#3': Cannot create inner bean 'org.springframework.integration.handler.MessageHandlerChain#3$child#2.handler' of type [org.springframework.integration.config.RouterFactoryBean] while setting bean property 'handlers' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#3$child#2.handler': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'expressionString' threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:153)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
... 24 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#3$child#2.handler': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'expressionString' threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
... 42 more
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'expressionString' threw exception; nested exception is org.springframework.expression.spel.SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'lcurly({)'
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
... 46 more
Anybody have any idea where I am doing wrong?
Please let me know if my question is not clear.
According to the StackTrace your issue is here:
<int:router expression="${customerservice.routing.jobChannel}"/>
Before to use such a difficult configuration you should be sure that your customerservice really returns all desired options.
Would be great, if you had shown how does that object look from Java perspective, rather than XML background
I am trying to setup a Spring Integration based Restful service. I am trying to avoid creating individual objects for request and response but instead use a HashMap for simple functions such as isUserAvailableForRegistration at service.
e.g
HashMap<String, String> isUserAvailableForRegistration(HashMap<String,String> request)
The following is the integration related context information:
<bean class="org.springframework.integration.http.inbound.UriPathHandlerMapping"/>
<int-http:inbound-gateway id="inboundGateway"
request-channel="incoming" reply-channel="outgoing"
supported-methods="POST" reply-timeout="5000"
path="/customer/isUserAvailable" />
<int:channel id="incoming" />
<int:channel id="outgoing" />
<int:service-activator id="activator" input-channel="incoming" ref="customerManagementGateway"
method="isUserAvailableForRegistration" output-channel="outgoing" requires-reply="true" />
<int:object-to-json-transformer id="outgoingJsonConverter"
input-channel="outgoing" />
<int:json-to-object-transformer id="incomingJsonConverter" input-channel="incoming" type="java.util.HashMap" />
While I can successfully test that I could marshall HashMap to JSON successfully, I am missing the configuration to unmarshall JSON data into HashMap.
I get the following exception:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.integration.dispatcher.AggregateMessageDeliveryException: All attempts to deliver Message to MessageHandlers failed. Multiple causes:
failed to transform message
org.springframework.expression.AccessException: Problem invoking method: public java.util.Map com.testapp.customer.CustomerManagementServiceActivator.isUserAvailableForRegistration(java.util.Map)
See below for the stacktrace of the first cause.
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
org.springframework.integration.dispatcher.AggregateMessageDeliveryException: All attempts to deliver Message to MessageHandlers failed. Multiple causes:
failed to transform message
org.springframework.expression.AccessException: Problem invoking method: public java.util.Map com.testapp.customer.CustomerManagementServiceActivator.isUserAvailableForRegistration(java.util.Map)
See below for the stacktrace of the first cause.
org.springframework.integration.dispatcher.UnicastingDispatcher.handleExceptions(UnicastingDispatcher.java:164)
org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:127)
org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:101)
org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:61)
org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:318)
org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:233)
org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:207)
org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:378)
org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:95)
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
org.springframework.integration.transformer.MessageTransformationException: failed to transform message
org.springframework.integration.transformer.AbstractTransformer.transform(AbstractTransformer.java:44)
org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:67)
org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:97)
org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:114)
org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:101)
org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:61)
org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:318)
org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:233)
org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:207)
org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:378)
org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:95)
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.ClassCastException: [B cannot be cast to java.lang.String
org.springframework.integration.json.JsonToObjectTransformer.transformPayload(JsonToObjectTransformer.java:30)
org.springframework.integration.transformer.AbstractPayloadTransformer.doTransform(AbstractPayloadTransformer.java:33)
org.springframework.integration.transformer.AbstractTransformer.transform(AbstractTransformer.java:33)
org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:67)
org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:97)
org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:114)
org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:101)
org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:61)
org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:318)
org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:233)
org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:207)
org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:378)
org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:95)
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Can anybody help me with figuring out what could possible be wrong ?
I have double checked the headers, hence i am sure that I it's something with the configuration or Jackson's support for unmarshalling to HashMap. Thanks for your time.
As Biju mentioned the integration graph wasnt correct, but the error was thrown even before the message reached json-to-object-transformer. After fixing the integration graph correctly i still was getting this error. after searching in spring integration forum, i found that mentioning request-payload-type in the int-http:inbound-gateway gateway solved the problem.
So the correct configuration is
<int-http:inbound-gateway id="inboundGateway"
request-channel="incoming" reply-channel="outgoing"
supported-methods="POST" reply-timeout="5000"
path="/customer/isUserAvailable" request-payload-type="String" />
Doesn't look like you have connected the different endpoints and channels correctly -
This is the flow that you have:
httpgateway->incoming(c)->customerManagementGateway->outgoing(c)->outgoingJsonConverter
->incomingJsonConverter
Both incomingJsonConverter and customerManagementGateway seem to be consuming off incoming channel
This may not be the main reason for the error message though, I think you need to convert the byte array to a String payload for the json transformer: try introducing this transformer also between your inputchannel and jsonconverter:
JsonToObjectTransformer:
<int:object-to-string-transformer input-channel="in" output-channel="out"/>
What does the following error message mean? Googling for MARKED_FOR_JOINED doesn't return any useful information.
ERROR org.hibernate.AssertionFailure.<init>(AssertionFailure.java:47): an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: Transaction MARKED_FOR_JOINED after isOpen() call
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:465)
at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:82)
at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:61)
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:39)
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean$ManagedEntityManagerFactoryInvocationHandler.invoke(AbstractEntityManagerFactoryBean.java:434)
at $Proxy30.createEntityManager(Unknown Source)
at org.springframework.orm.jpa.EntityManagerFactoryUtils.doGetTransactionalEntityManager(EntityManagerFactoryUtils.java:195)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:175)
at $Proxy31.createNativeQuery(Unknown Source)
at com.ipass.rbac.svc.FooTst.insertFoo(FooTst.java:20)
at com.ipass.rbac.svc.FooTst$$FastClassByCGLIB$$7c736518.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at com.ipass.rbac.svc.FooTst$$EnhancerByCGLIB$$da856476.insertFoo(<generated>)
at com.ipass.rbac.svc.SingleTst.testFoo(SingleTst.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
The error message occurs when I do the following:
#Transactional
public void insertFoo() {
em.createNativeQuery("INSERT INTO Foo (id) VALUES (:id)")
.setParameter("id", System.currentTimeMillis() % Integer.MAX_VALUE )
.executeUpdate();
}
I'm using spring with hibernate as the jpa provider. I'm trying to do a simple transaction using the Bitronix connection pool and transaction manager. The exact same error occurs when I switch from the Bitronix transaction manager to the Atomikos transaction manager. The error doesn't occur when using jotm. But then jotm doesn't seem to do anything at all for me when it comes to having actual transactions.
Here is the bitronix transaction manager configuration:
<bean id="btmConfig" factory-method="getConfiguration"
class="bitronix.tm.TransactionManagerServices">
<property name="serverId" value="spring-btm" />
<property name="journal" value="null" />
</bean>
<bean id="btmManager" factory-method="getTransactionManager"
class="bitronix.tm.TransactionManagerServices" depends-on="btmConfig"
destroy-method="shutdown" />
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="btmManager" />
<property name="userTransaction" ref="btmManager" />
<property name="allowCustomIsolationLevels" value="true" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
This problem was caused because I was using enhydra xapool as my connection pool. I eventually got things working by using the Bitronix pool instead. See spring transactional cpool. Which one do I use? for full instructions on how I did it.