This is an intermittent problem, roughly 4/5 starts hit null pointer. Camel-Context.xml is below.
Error:
2011-10-18 08:31:25,245 [main ] INFO MainSupport - Apache Camel 2.8.0 stopping
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [D:\Users\michaelb\workspace\camel-example-spring-eda\target\classes\META-INF\spring\camel-context-NERD.xml]; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:185)
at org.apache.camel.spring.Main.doStart(Main.java:139)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at org.apache.camel.impl.MainSupport.run(MainSupport.java:136)
at org.apache.camel.impl.MainSupport.run(MainSupport.java:322)
at com.softwareag.eda.NERD.main(NERD.java:39)
Caused by: java.lang.NullPointerException
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.checkOverrideProperties(ClassBeanInfoImpl.java:190)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:171)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:494)
Camel-Context.xml
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
org.apache.camel.example.spring.eda
<!-- Announce route -->
<route id="Announcer" startupOrder="3">
<from uri="file:src/data?noop=true" />
<choice>
<when>
<xpath>$eventtype = 'shipment'</xpath>
<to uri="jmsEDA:topic:orderMgmt" />
</when>
<otherwise>
<to uri="jmsEDA:topic:orderMgmt" />
</otherwise>
</choice>
</route>
<!-- Listen route -->
<route id="Listener" startupOrder="2">
<from uri="jmsEDA:topic:orderMgmt" />
<to uri="file://target/test?noop=true" />
<to uri="outputToScreen" />
<log message="done" />
</route>
</camelContext>
<!-- EDA JMS endpoint URL -->
<bean id="jmsEDA" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL"
value="vm://localhost?broker.persistent=false&broker.useJmx=false" />
</bean>
</property>
</bean>
<!-- Screen output endpoint -->
<bean id="outputToScreen"
class="com.softwareag.eda.NERD.outputToScreen">
</bean>
</beans>
I came across your question due to experiencing the same problem. On Feb 18, 2012 the 2.2.5 version of JAXB was released. After upgrading to 2.2.5, the problem seems to have been resolved. So far, it hasn't occurred again in testing.
See http://jaxb.java.net/ for details.
For reference, my configuration uses Camel 2.8.4 and Spring 3.0.5.
The problem is also mentioned here and it has an statement from Claus Ibsen here. You solved it already, it is Java 7.
Same thing for 1.6.0_30-b12 (32 bit) with Camel 2.8 and 2.9
I've downgraded my jaxb-impl version from 2.2.4 to 2.2.3.
I think it's not a JDK, but a JAXB issue :
C:\java\jdk1.7.0_03\bin\xjc.exe -version
xjc 2.2.4
It is fixed in JBoss 7.1.2. So you need to fix it yourself in JBoss 7.1.1
You can find more about this issue here.
Related
I am trying to build a spring integration application, which has the following configuration (the culprit seems to be the channel xsltSpecific) :
<beans:beans>
<channel id="channel1"></channel>
<channel id="channel2"></channel>
<channel id="xsltSpecific"></channel>
<channel id="xsltSpecificDelayed"></channel>
<channel id="xsltCommon"></channel>
<channel id="irdSpecificUnmarshallerChannel"></channel>
<channel id="irdSpecificInputChannel"></channel>
<file:outbound-channel-adapter
directory="${dml.ird.directory}" channel="channel1"
auto-create-directory="true" filename-generator="timestampedFileNameGenerator">
</file:outbound-channel-adapter>
<recipient-list-router input-channel="fileChannel">
<recipient channel="channel1" selector-expression="${dml.data.logs.enable}" />
<recipient channel="channel2" />
</recipient-list-router>
<recipient-list-router input-channel="channel2">
<recipient channel="xsltSpecificDelayed"></recipient>
<recipient channel="xsltCommon"></recipient>
</recipient-list-router>
<delayer id="specificDelayer" input-channel="xsltSpecificDelayed" default-delay="5000" output-channel="xsltSpecific"/>
<jms:message-driven-channel-adapter
id="jmsInboundAdapterIrd" destination="jmsInputQueue" channel="fileChannel"
acknowledge="transacted" transaction-manager="transactionManager"
error-channel="errorChannel" client-id="${ibm.jms.connection.factory.client.id}"
subscription-durable="true" durable-subscription-name="${ibm.jms.subscription.id1}" />
<si-xml:xslt-transformer input-channel="xsltCommon" output-channel="jmsInputChannel"
xsl-resource="classpath:summit-hub-to-cpm-mapping.xsl" result-transformer="resultTransformer" >
</si-xml:xslt-transformer>
<si-xml:xslt-transformer input-channel="xsltSpecific" output-channel="irdSpecificUnmarshallerChannel"
xsl-resource="classpath:summit-hub-specific.xsl" result-transformer="resultTransformer" >
</si-xml:xslt-transformer>
<si-xml:unmarshalling-transformer id="irdUnmarshaller"
unmarshaller="irdUnmarshallerDelegate" input-channel="irdSpecificUnmarshallerChannel"
output-channel="saveSpecificTradeChannel" />
<beans:bean id="irdUnmarshallerDelegate"
class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<beans:property name="schema"
value="summit-hub-specific.xsd" />
<beans:property name="contextPath"
value="com.h.i.c.d.i.mapping" />
</beans:bean>
<beans:bean id="resultTransformer" class="org.springframework.integration.xml.transformer.ResultToStringTransformer" />
<service-activator ref="specificTradeService" input-channel="saveSpecificTradeChannel"
requires-reply="false" method="save"/>
<file:inbound-channel-adapter directory="${dml.retry.directoryForIrd}"
channel="fileChannelAfterRetry" auto-create-directory="true"
prevent-duplicates="false" filename-regex=".*\.(msg|xml)" queue-size="50" >
<poller fixed-delay="${dml.retry.delay}" max-messages-per-poll="50">
<transactional transaction-manager="transactionManager" />
</poller>
</file:inbound-channel-adapter>
<channel id="fileChannel"/>
<channel id="fileChannelAfterRetry"/>
<file:file-to-string-transformer
input-channel="fileChannelAfterRetry" output-channel="fileChannel"
delete-files="true" />
<beans:import resource="classpath:cpm-dml-common-main.xml" />
</beans:beans>
But I am having the following exception :
org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'org.springframework.context.support.GenericApplicationContext#6950e31.xsltSpecific'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
What does this exception mean ?
Also, I am not able to spot the problem, can you help me fix this issue ?
UPDATE
Sorry, I didn't give the whole context earlier, because I didn't think it was relevant.
The exception arises during a test derived from AbstractTransactionalJUnit4SpringContextTests, which closed the application context at the end of the test, before the message had a chance to get to the end.
I've added a Thread.sleep(10000) at the end of the test, and the exception doesn't happen anymore.
The xsltSpecific is just a default DirectChannel with a UnicastingDispatcher to deliver messages to channel's subscribers.
According your configuration you send a message to this channel from the:
<delayer id="specificDelayer" input-channel="xsltSpecificDelayed" default-delay="5000" output-channel="xsltSpecific"/>
And also it looks like you really have a subscriber to this channel:
<si-xml:xslt-transformer input-channel="xsltSpecific" output-channel="irdSpecificUnmarshallerChannel"
xsl-resource="classpath:summit-hub-specific.xsl" result-transformer="resultTransformer" >
</si-xml:xslt-transformer>
What is really not clear when this defined subscriber is lost. It doesn't look like you have an auto-startup="false" on this endpoint, but on the other hand maybe you really stop it at runtime...
Would you mind to share more stack trace on the matter? I want to see who is an original caller for that lost message.
I have some problem. I need to take the route or all CamelContext from blueprint file. How can i did it?
route.xml
I have tried to add route via RouteDefinitions but it throws exceptions because it expected spring namespace but i use blueprint namespace. I use cxf as implementation of JAX-RS. There is another way how to do it better.
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<bean id="weatherMailService" class="com.test.mail.MailSenderImpl"/>
<service ref="weatherMailService" interface="com.test.mail.MailSender"/>
<bean id="serviceProcessor" class="com.test.mail.MailSenderImpl"/>
<bean id="context" class="com.test.mail.MailSenderImpl"></bean>
<camelContext id="ctx" xmlns="http://camel.apache.org/schema/blueprint">
<route id="mail">
<from uri="direct:start"/>
<setBody>
<constant>Test</constant>
</setBody>
<setHeader headerName="subject">
<simple>Weather</simple>
</setHeader>
<process ref="serviceProcessor"/>
<to uri="smtps://smtp.gmail.com:465?username=RAW(*****#gmail.com)&password=******&to=******#gmail.com"/>
<to uri="log:start"/>
<process ref="context"></process>
</route>
</camelContext>
I would like to get CamelContext in java code. How can i did it? Thank you
I am trying out a sample using swagger component of camel.
Below is my camel-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<!-- a bean for user services -->
<bean id="StudentService"
class="temp.org.impl.StudentService" />
<camelContext id="mycamel" xmlns="http://camel.apache.org/schema/spring">
<!-- configure rest to use the camel-servlet component, and use json binding
mode -->
<!-- and tell to output json in pretty print mode -->
<restConfiguration component="servlet" bindingMode="json"
contextPath="school/bo" port="8080">
<dataFormatProperty key="prettyPrint" value="true" />
</restConfiguration>
<!-- defines the rest services using the context-path /user -->
<rest path="/students" consumes="application/json" produces="application/json">
<description>Student service</description>
<!-- this is a rest GET to view an user by the given id -->
<get outType="temp.org.model.Student[]">
<description>Get All Students</description>
<responseMessage code="200" message="Student details" />
<to uri="bean:StudentService?method=getStudents()" />
</get>
<post type="temp.org.model.Student"
outType="temp.org.model.Student[]">
<description>Query Student Object</description>
<param name="body" type="body" description="Querying Student Object"
required="true" />
<responseMessage code="404" message="Student not found" />
<responseMessage code="200" message="Student details" />
<route id="getStudentRoute">
<to uri="bean:StudentService?method=getStudent(${body})" />
<filter>
<simple>${body} == null</simple>
<setHeader headerName="Exchange.HTTP_RESPONSE_CODE">
<constant>404</constant>
</setHeader>
</filter>
<filter>
<simple>${body} != null</simple>
<setHeader headerName="Exchange.HTTP_RESPONSE_CODE">
<constant>200</constant>
</setHeader>
</filter>
</route>
</post>
<delete type="temp.org.model.Student">
<description>Delete alarm</description>
<param name="body" type="body" description="Delete Student Object"
required="true" />
<responseMessage code="404" message="Student not found" />
<responseMessage code="200" message="Student deleted Successfully" />
<to uri="bean:StudentService?method=deleteStudent(${body})" />
</delete>
<post type="temp.org.model.Student">
<description>Insert alarm</description>
<param name="body" type="body" description="Insert Student Object"
required="true" />
<to uri="bean:StudentService?method=insertStudent(${body})" />
</post>
</rest>
</camelContext>
</beans>
Now for this example i am using camel version 2.16 which has support for swagger.
The problem is when i try to deploy the project in tomcat. While tomcat tries to read the camel-context.xml, it throws error as :
2016-03-08 15:57:00,736 [ost-startStop-1] ERROR ContextLoader - Context initialization failed
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToStartRouteException: Failed to start route route1 becau
se of Multiple consumers for the same endpoint is not allowed: Endpoint[servlet:/students?httpMethodRestrict=POST]
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1642)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:138)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:340)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMult
icaster.java:151)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMult
icaster.java:128)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:3
31)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:
775)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434
)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.camel.FailedToStartRouteException: Failed to start route route1 because of Multiple consumers for
the same endpoint is not allowed: Endpoint[servlet:/students?httpMethodRestrict=POST]
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:3486)
at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3462)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3392)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3160)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3016)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2812)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2808)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2831)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2808)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2777)
at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:270)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:136)
... 22 more
Does camel-swagger support multiple post methods in a rest service? If yes can anybody provide me a sample to overcome the error i am getting..
Looking forward to your solutions. Thanks in advance..
I have a service bundle where I want to compress a response by using CXF GZIPFeature. The bundle is deployed on JBoss Fuse(jboss-fuse-6.1.0.redhat-379). Camel route configuraion is:
<cxf:bus id="cxf" name ="cxf">
<cxf:features>
<bean class="org.apache.cxf.transport.common.gzip.GZIPFeature">
<property name="threshold">
<value>1</value>
</property>
</bean>
</cxf:features>
</cxf:bus>
<camel:camelContext ...>
<camel:route id="test-server">
<camel:to uri="cxfbean:servicebeans?bus=#cxf&providers=#providers" />
</camel:route>
</camel:camelContext>
But this throws classcast exception:
java.lang.ClassCastException: org.apache.cxf.transport.common.gzip.GZIPOutInterceptor$GZipThresholdOutputStream cannot be cast to org.apache.cxf.io.CachedOutputStream
at org.apache.camel.component.cxf.transport.CamelDestination$CamelOutputStream.commitOutputMessage(CamelDestination.java:284)[204:org.apache.camel.camel-cxf-transport:2.12.0.redhat-610379]
at org.apache.camel.component.cxf.transport.CamelDestination$CamelOutputStream.doClose(CamelDestination.java:296)[204:org.apache.camel.camel-cxf-transport:2.12.0.redhat-610379]
at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:220)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:241)[:1.7.0_67]
at org.apache.cxf.io.AbstractWrappedOutputStream.close(AbstractWrappedOutputStream.java:77)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:102)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)[164:org.apache.cxf.cxf-api:2.7.0.redhat-610379]
Is there a legal way to use CXF GZIPFeature in the route? I don't want to use Camel's DataFormat to gzip.
I'm using servicemix-camel-cxf and had nearly the same problem. In the end I decided to simply add this in route:
<marshal>
<gzip/>
</marshal>
Check it out - maybe it will help you too.
But in that case you have to set Content-Type: gzip header.
Try to add
<setHeader headerName="Content-Type">
<constant>gzip</constant></setHeader>
However for me it didn't help, so I added header in java code. =)
I recently upgraded to Camel 2.14.1 and have been playing around the new REST DSL. Before the upgrade I used restlet within a servlet container, i.e. with this in my web.xml:
<!-- Restlet Servlet -->
<servlet>
<servlet-name>RestletServlet</servlet-name>
<servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class>
<init-param>
<param-name>org.restlet.component</param-name>
<param-value>RestletComponent</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>RestletServlet</servlet-name>
<url-pattern>/rs/*</url-pattern>
</servlet-mapping>
And this in my camel context:
<bean id="RestletComponent" class="org.restlet.Component" />
<bean id="RestletComponentService" class="org.apache.camel.component.restlet.RestletComponent">
<constructor-arg index="0">
<ref bean="RestletComponent" />
</constructor-arg>
</bean>
This does not work with the REST DSL.
I'm testing it out with this simple route:
<rest>
<get uri="/hello">
<to uri="direct:hello"/>
</get>
</rest>
<route id="hello">
<from uri="direct:hello"/>
<setBody><constant>Dolly</constant></setBody>
</route>
The REST DSL successfully finds the RestletComponent Bean defined in my web.xml, but the bean does not have a camelContext associated with it, so I get a null pointer exception when the code tries to access the context.
Basically, I'm beginning to suspect that the REST DSL is incompatible with Restlet within a servlet container. I want the hosting servlet container to handle the incoming requests, I don't want to have to spawn a separate restlet server process (on a new port) for my camel contexts.
Am I out of luck?
OK, to make things easier, I started from one of the existing examples: camel-example-restlet-jdbc which uses restlet and altered it so it uses the new rest dsl.
Here's the xml-dsl.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<import resource="common.xml" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
<rest>
<post uri="/persons">
<route>
<setBody>
<simple>insert into person(firstName, lastName) values('${header.firstName}','${header.lastName}')
</simple>
</setBody>
<to uri="jdbc:dataSource"/>
<setBody>
<!--<simple>select * from person ORDER BY id desc OFFSET 1 ROWS</simple>-->
<simple>select * from person where id in (select max(id) from person)</simple>
</setBody>
<to uri="jdbc:dataSource"/>
</route>
</post>
<get uri="/persons/{personId}">
<route>
<setBody>
<simple>select * from person where id = ${header.personId}</simple>
</setBody>
<to uri="jdbc:dataSource"/>
</route>
</get>
<get uri="/persons">
<route>
<setBody>
<constant>select * from person</constant>
</setBody>
<to uri="jdbc:dataSource"/>
</route>
</get>
</rest>
</camelContext>
</beans>
This doesn't work. It throws java.net.SocketException: Permission denied
I haven't used the Rest DSL before, but according to the documentation you can explicitly let Camel know that you are using the restlet component:
<restConfiguration component="RestletComponent" port="9091"> <componentProperty key="foo" value="123"/> </restConfiguration>
It does say that it will lookup to check whether there are any components that integrates with the DSL if this is not specified, but I guess but it's worth giving it a shot.
On a side note, I found it a bit odd that you give your spring beans IDs starting with an uppercase.