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..
Related
Here is my spring configuration.
Spring.xml
-------------
<!-- Outgoing SOAP client endpoint -->
<cxf:cxfEndpoint id="serviceEndpoint" address="${endpointAddress}"
wsdlURL="${wsdlAddress}" endpointName="${portName}" serviceName="${serviceName}">
<!-- The interceptors - needed to log the SOAP requests and responses -->
<!-- They can be removed, when no logging is needed -->
<cxf:inInterceptors>
<ref bean="loggingInInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="loggingOutInterceptor" />
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="loggingOutInterceptor" />
</cxf:outFaultInterceptors>
<cxf:inFaultInterceptors>
<ref bean="loggingInInterceptor" />
</cxf:inFaultInterceptors>
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
</cxf:properties>
</cxf:cxfEndpoint>
<http:conduit name="*.http-conduit">
<http:tlsClientParameters disableCNCheck="${disableHostnameCheck}">
<sec:keyManagers keyPassword="${keystorePassword}">
<sec:keyStore type="JKS" password="${keystorePassword}"
file="${keystoreLocation}" />
</sec:keyManagers>
<sec:trustManagers>
<sec:keyStore type="JKS" password="${truststorePassword}"
file="${truststoreLocation}" />
</sec:trustManagers>
<sec:cipherSuitesFilter>
<!-- these filters ensure that a ciphersuite with export-suitable or
null encryption is used, but exclude anonymous Diffie-Hellman key change
as this is vulnerable to man-in-the-middle attacks -->
<sec:include>.*_EXPORT_.*</sec:include>
<sec:include>.*_EXPORT1024_.*</sec:include>
<sec:include>.*_WITH_DES_.*</sec:include>
<sec:include>.*_WITH_AES_.*</sec:include>
<sec:include>.*_WITH_NULL_.*</sec:include>
<sec:exclude>.*_DH_anon_.*</sec:exclude>
</sec:cipherSuitesFilter>
</http:tlsClientParameters>
<http:client AutoRedirect="true" Connection="Keep-Alive"
ReceiveTimeout="${connectionTimeout}" ConnectionTimeout="${connectionTimeout}" />
</http:conduit>
Here is the Camel route configuration
-------------
<from ...
<to uri="cxf:bean:serviceEndpoint" />
This works well and we can have the soap request/response logged into the log file. Here soap request with soap header is generated by cxf.
Do we have a way to capture the soap request and response into camel Exchange? I have to send an email attached with soap request and response if the service call is failed.
Have tried using thread local but it doesn't seems to work expected.
Suggestion:
You have it in CXF Interceptors - take a look at them.
I guess, you can send your e-mail out of it.
Start from org.apache.cxf.phase.AbstractPhaseInterceptor class - there are bunch of different ones for different phases.
P.S. From first glance org.apache.cxf.binding.soap.saaj.SAAJInInterceptor and
org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor could be good candidates...
I'm pretty new to MuleESB. I'm using Mule Standalone 3.8.1 with a configuration to filter HTTP requests using the xpath3() function. The configuration I have used is as follows.
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" />
<http:request-config name="HTTP_Request_Configuration" host="example.com" port="8081" basePath="basePath" responseTimeout="120000" />
<custom-transformer name="XML_Transformer" class="org.mule.module.xml.transformer.XmlToOutputHandler"/>
<message-properties-transformer name="Response_Error_Transformer">
<add-message-property key="http.status" value="500"/>
<add-message-property key="Content-Type" value="text/xml" />
</message-properties-transformer>
<message-properties-transformer name="Response_Transformer">
<add-message-property key="Content-Type" value="text/xml" />
</message-properties-transformer>
<set-payload name="Create_Error_Response" value="
<PurchaseOrder PurchaseOrderNumber="99503" OrderDate="1999-10-20">
<fault>
<code>500</code>
<message>#[flowVars['errorMessage']]</message>
</fault>
</PurchaseOrder>" />
<flow name="Choice_Flow">
<http:listener config-ref="HTTP_Listener_Configuration" path="productFilter" />
<choice>
<when expression="#[xpath3('//Item[1]/ProductName') == 'Laptop']">
<transformer ref="XML_Transformer"/>
<http:request config-ref="HTTP_Request_Configuration" path="EchoService" method="POST" />
<flow-ref name="Response_Transformer" />
</when>
<otherwise>
<flow-ref name="Response_Error_Transformer" />
<set-variable variableName="errorMessage" value="First item must be a Laptop" />
<flow-ref name="Create_Error_Response" />
</otherwise>
</choice>
</flow>
When I'm sending HTTP requests at 10 threads it's working fine. But, then when I tried sending requests at 500 threads, some of the requests got failed. The request is an XML with 2500 Item elements. I don't see any descriptive errors in the logs or anywhere, but the requests got failed. After this happens, some of the requests got failed even for small thread numbers, and I couldn't find any error in files in the logs directory. Only error I see in the mule.log file is as follows. This is written at the first occurrence of this error. Then, simply, nothing.
Exception: java.lang.NoClassDefFoundError thrown from the UncaughtExceptionHandler in thread "[default].http.listener(6)"
Can someone please explain me what's going on here? How to do this without any error? Is something wrong with my configuration?
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.
I am using spring integration to make TCP call to server by providing some message and getting response back. I prefer to use channel adapter to send and receive bulk messages. The problem I am facing is with the response channel. Getting "Dispatcher has no subscribers for channel " for response channel.
Everything is working fine except the response not getting transported on response channel. I can see the handshaking at server and the response in the log being put on the response and logger channels. But after that exception is thrown. Configuration setup is:
<gateway id="clientPositionsGateway" service-interface="MyGatewayInterface">
<method name="fetchClientPositions" request-channel="clientPositionsRequestChannel" />
</gateway>
<channel id="clientPositionsRequestChannel" />
<splitter input-channel="clientPositionsRequestChannel"
output-channel="singleClientPositionsRequestChannel" />
<channel id = "singleClientPositionsRequestChannel" />
<transformer
input-channel="singleClientPositionsRequestChannel"
output-channel="dmQueryRequestChannel"
ref="dmPosBaseQueryTransformer" />
<channel id = "dmQueryRequestChannel">
<!-- <dispatcher task-executor="executor"/> -->
</channel>
<ip:tcp-connection-factory id="csClient"
type="client"
host="somehost"
port="12345"
single-use="true"
deserializer="connectionSerializeDeserialize"
/>
<ip:tcp-outbound-channel-adapter id="dmServerOutboundAdapter"
channel="dmQueryRequestChannel"
connection-factory="csClient"
order="2"
/>
<ip:tcp-inbound-channel-adapter id="dmServerInboundAdapter"
channel="dmQueryResponseChannel"
connection-factory="csClient"
error-channel="errorChannel"/>
<channel id="dmQueryResponseChannel"/>
As Artem said in his comment, 'Dispatcher has no subscribers' means here that there is no endpoint configured to receive the response on dmQueryResponseChannel, or the endpoint configured with that channel as its input channel is not started.
In any case, even when you resolve that, using independent adapters for request/response scenarios is tricky because the framework has no way to automatically correlated the response to the request. That's what the outbound gateway is for. You can use collaborating adapters, but you have to deal with the correlation yourself. If you are using a request/reply gateway to initiate the flow, you will have to use a technique such as the one explored in the tcp-client-server-multiplex sample. This is because using independent adapters means you'll lose the replyChannel header used to get the response back to the gateway.
Or, you can use a void returning gateway to send the request, and an <int:outbound-channel-adapter/> so the framework will call back with the response and you can do your own correlation programmatically.
If your clientPositionsGateway is invoked from client threads, there is no reason to use executor channels. If you do million loop clientPositionsGateway try to use Future gateway: http://docs.spring.io/spring-integration/docs/2.2.5.RELEASE/reference/html/messaging-endpoints-chapter.html#async-gateway and again: without executor channels. And I don't see reason to use reply-channel on both gateways.
And one more: you have <splitter> before <tcp:outbound-gateway>, but where is an <aggregator> after <tcp:outbound-gateway>?..
In your current case you get reply from your clientPositionsGateway, all others will be dropped, because TemporaryReplyChannel will be already closed.
public interface ClientPositionsGateway {
String fetchClientPositions(List<String> clientList);
}
Here is a code that solved my Problem :
#ContextConfiguration(locations={"/clientGIM2Position.xml"})
#RunWith(SpringJUnit4ClassRunner.class)
public class GetClientPositionsTest {
#Autowired
ClientPositionsGateway clientPositionsGateway;
#Test
public void testGetPositions() throws Exception {
String positions = clientPositionsGateway.fetchClientPositions(clientList);
System.out.println("returned !!!!" + positions);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/integration"
xmlns:ip="http://www.springframework.org/schema/integration/ip"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<!-- intercept and log every message -->
<logging-channel-adapter id="logger" level="DEBUG" />
<wire-tap channel = "logger" />
<gateway id="clientPositionsGateway"
service-interface="com.example.ClientPositionsGateway">
<method name="fetchClientPositions" request-channel="clientPositionsRequestChannel" reply-channel="dmQueryResponseChannel"/>
</gateway>
<channel id="clientPositionsRequestChannel" />
<splitter input-channel="clientPositionsRequestChannel"
output-channel="singleClientPositionsRequestChannel" />
<channel id = "singleClientPositionsRequestChannel" />
<transformer
input-channel="singleClientPositionsRequestChannel"
output-channel="dmQueryRequestChannel"
ref="dmPosBaseTransQueryTransformer" />
<channel id = "dmQueryRequestChannel">
<dispatcher task-executor="executor"/>
</channel>
<ip:tcp-connection-factory id="csClient"
type="client"
host="hostserver"
port="22010"
single-use="true"
deserializer="connectionSerializeDeserialize"
/>
<ip:tcp-outbound-gateway id="dmServerGateway"
request-channel="dmQueryRequestChannel"
reply-channel="dmQueryResponseChannel"
connection-factory="csClient" />
<channel id="dmQueryResponseChannel">
<dispatcher task-executor="executor"/>
</channel>
<channel id="serverBytes2StringChannel" />
<bean id="connectionSerializeDeserialize" class="com.example.DMQueryResponseSerializer"/>
<bean id="dmPosBaseTransQueryTransformer" class="com.example.DMPOSBaseTransQueryTransformer"/>
<task:executor id="executor" pool-size="5"/>
</beans:beans>
Configuration settings:
<gateway id="clientPositionsGateway" service-interface="com.example.ClientPositionsGateway">
<method name="fetchClientPositions" request-channel="clientPositionsRequestChannel" reply-channel="dmQueryResponseChannel"/>
</gateway>
<channel id="clientPositionsRequestChannel" />
<splitter input-channel="clientPositionsRequestChannel"
output-channel="singleClientPositionsRequestChannel" />
<channel id = "singleClientPositionsRequestChannel" />
<transformer
input-channel="singleClientPositionsRequestChannel"
output-channel="dmQueryRequestChannel"
ref="dmPosBaseQueryTransformer" />
<logging-channel-adapter channel="clientBytes2StringChannel"/>
<channel id = "dmQueryRequestChannel">
<dispatcher task-executor="executor"/>
</channel>
<ip:tcp-connection-factory id="csClient"
type="client"
host="serverHost"
port="22010"
single-use="true"
deserializer="connectionSerializeDeserialize"
/>
<ip:tcp-outbound-channel-adapter id="dmServerOutboundAdapter"
channel="dmQueryRequestChannel"
connection-factory="csClient"
/>
<ip:tcp-inbound-channel-adapter id="dmServerInboundAdapter"
channel="dmQueryResponseChannel"
connection-factory="csClient"
error-channel="errorChannel"/>
<transformer input-channel="dmQueryResponseChannel" output-channel="clientBytes2StringChannel" ref="dmPOSBaseQueryResponseTransformer"
/>
<channel id="dmQueryResponseChannel"/>
<channel id="clientBytes2StringChannel"/>
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.