Hi, Next time, it should be helpful if you can show us some of your code. I'll try to answer you and I hope I well understood your problem.
If you use JAXB in servicemix (or in an OSGi environment), please pay attention : In servicemix, every bundle has its own Class loader. So when you want to use the JAXB functions (Unmarshall/Marshall) in your bundle B with your JAXB classes that are deployed in a bundle A, you have to specified which ClassLoader JAXB must use. Actually, by default, it uses the ClassLoader of the current thread. So if you are in the bundle B, it use the Class loader of the bundle B. If you want to use the ClassLoader of the bundle A (that's what you should do in this case), you can do like : //specify which class loader JAXB should use JAXBContext jc = JAXBContext.newInstance(ObjectFactory.class.getPackage().getName(), ObjectFactory.class.getClassLoader()); And then you can use the Marshaller/Unmarshaller by calling jc.createMarshaller()/jc.createUnmarshaller() I hope it can help you. KR, Arnaud Deprez Analyst-Programmer Acquiring Back-Office +32 2 727 72 09 [email protected] Chaussee de Haecht 1442 Haachtsesteenweg 1130 Brussels Belgium atosworldline.be please don't print unless you really need to -----Original Message----- From: napster1 [mailto:[email protected]] Sent: mercredi 22 août 2012 11:56 To: [email protected] Subject: Servicemix 4.4.2: JaxbException: ClassCastException after deploying a camel route Hello everyone, Need your all help in resolving the below issue. I have developed a camel route which just connects to a jboss jms queue, reads from it and then displays a log message. My Camel-route.xml is : <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://camel.apache.org/schema/osgi" xmlns:osgix="http://www.springframework.org/schema/osgi-compendium" xmlns:ctx="http://www.springframework.org/schema/context" xmlns:amq="http://activemq.apache.org/schema/core" xmlns:jee="http://www.springframework.org/schema/jee" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://camel.apache.org/schema/osgi http://camel.apache.org/schema/osgi/camel-osgi.xsd http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd"> <osgi:camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="jbossjms:queue:input" /> <to uri="bean:inQueueReader?method=grabFromQueue" /> <to uri="log:ObjectsReadsuccessfulyfrominQueue" /> </route> </osgi:camelContext> <bean id="jbossjms" class="org.apache.camel.component.jms.JmsComponent"> <property name="connectionFactory" ref="jbossConnectionFactory"/> <property name="brokerURL" value="tcp://localhost:1099"/> </bean> <jee:jndi-lookup id="jbossConnectionFactory" jndi-name="/ConnectionFactory"> <jee:environment> java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=jnp://localhost:1099 java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces </jee:environment> </jee:jndi-lookup> <bean id="inQueueReader" class="com.shailesh.ReadJbossQueue" /> <osgix:cm-properties id="preProps" persistent-id="com.shailesh.CamelWithJmsAndSpring3"> <prop key="prefix">MyTransform</prop> </osgix:cm-properties> <ctx:property-placeholder properties-ref="preProps" /> </beans> When i deploy the route to servicemix , I am getting the below exception : org.springframework.beans.factory.BeanDefinitionStoreException: Failed to create the JAXB binder; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: ClassCastException: attempting to cast jar:file:/C:/Program%20Files/Java/jdk1.6.0_21/jre/lib/rt.jar!/javax/xml/bind/JAXBContext.class to bundle://80.0:1/javax/xml/bind/JAXBContext.class. Please make sure that you are specifying the proper ClassLoader. - with linked exception: [javax.xml.bind.JAXBException: ClassCastException: attempting to cast jar:file:/C:/Program%20Files/Java/jdk1.6.0_21/jre/lib/rt.jar!/javax/xml/bind/JAXBContext.class to bundle://80.0:1/javax/xml/bind/JAXBContext.class. Please make sure that you are specifying the proper ClassLoader. ] I see here that, even though servicemix is having its own JAXB implementation , it is still accessing the JDK's JAXB api. I am using JDK 6 update 21 and servicemix version is 4.4.2. Could anyone please suggest me what can be done here to resolve this exception ? I am in urgent need and already spent 2 days in googling this stuff. Quick response will be appreaciated . Thanks -- View this message in context: http://servicemix.396122.n5.nabble.com/Servicemix-4-4-2-JaxbException-ClassCastException-after-deploying-a-camel-route-tp5714220.html Sent from the ServiceMix - User mailing list archive at Nabble.com. Atos Worldline SA/NV - Chaussee de Haecht 1442 Haachtsesteenweg - 1130 Brussels - Belgium RPM-RPR Bruxelles-Brussel - TVA-BTW BE 0418.547.872 Bankrekening-Compte Bancaire-Bank Account 310-0269424-44 BIC BBRUBEBB - IBAN BE55 3100 2694 2444 "The information contained in this e-mail and any attachment thereto is confidential and may contain information which is protected by intellectual property rights. This information is intended for the exclusive use of the recipient(s) named above. This e-mail does not constitute any binding relationship or offer toward any of the addressees. If you are not one of the addressees , one of their employees or a proxy holder entitled to hand over this message to the addressee(s), any use of the information contained herein (e.g. reproduction, divulgation, communication or distribution,...) is prohibited. If you have received this message in error, please notify the sender and destroy it immediately after. The integrity and security of this message cannot be guaranteed and it may be subject to data corruption, interception and unauthorized amendment, for which we accept no liability."
