You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/07/23 10:05:26 UTC

[1/5] git commit: Upgrade to disruptor 3.1.1. Added note to camel-disruptor features how to install it

Updated Branches:
  refs/heads/camel-2.10.x ff5cf8baf -> f0749e913
  refs/heads/camel-2.11.x e118998f1 -> 5e8235a80
  refs/heads/master e7563a761 -> 651709060


Upgrade to disruptor 3.1.1. Added note to camel-disruptor features how to install it


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9beccf1f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9beccf1f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9beccf1f

Branch: refs/heads/master
Commit: 9beccf1f3b7bb119fbf4b328b1833357b64b5a4b
Parents: e7563a7
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 08:05:19 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 08:05:19 2013 +0200

----------------------------------------------------------------------
 parent/pom.xml                                           | 2 +-
 platforms/karaf/features/src/main/resources/features.xml | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9beccf1f/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index f5fd691..cf225a5 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -109,7 +109,7 @@
     <cxf-xjc-utils-version>2.6.0</cxf-xjc-utils-version>
     <deltaspike-version>0.3-incubating</deltaspike-version>
     <derby-version>10.10.1.1</derby-version>
-    <disruptor-version>3.1.0</disruptor-version>
+    <disruptor-version>3.1.1</disruptor-version>
     <dnsjava-version>2.1.1</dnsjava-version>
     <dnsjava-bundle-version>2.1.1_1</dnsjava-bundle-version>
     <dom4j-bundle-version>1.6.1_5</dom4j-bundle-version>

http://git-wip-us.apache.org/repos/asf/camel/blob/9beccf1f/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index d858050..9b46175 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -221,15 +221,14 @@
     <bundle>mvn:org.apache.camel/camel-cxf-transport/${project.version}</bundle>
     <bundle>mvn:org.apache.camel/camel-cxf/${project.version}</bundle>
   </feature>
-<!-- TODO: Does not work due: No export found to match sun.misc (imported by mvn:com.lmax/disruptor/3.0.1)  
   <feature name='camel-disruptor' version='${project.version}' resolver='(obr)' start-level='50'>
+    <details>The camel-disruptor feature can only run on a SUN JVM. You need to add the package sun.misc to the java platform packages in the etc/jre.properties file.</details>
     <bundle dependency='true'>mvn:com.lmax/disruptor/${disruptor-version}</bundle>
     <feature version='${project.version}'>camel-core</feature>
     <bundle>mvn:org.apache.camel/camel-disruptor/${project.version}</bundle>
   </feature>
--->
   <feature name='camel-dns' version='${project.version}' resolver='(obr)' start-level='50'>
-    <details>The camel-dns feature can only run on a SUN JVM. You need to ddd the package sun.net.spi.nameservice to the java platform packages in the etc/jre.properties file.</details>
+    <details>The camel-dns feature can only run on a SUN JVM. You need to add the package sun.net.spi.nameservice to the java platform packages in the etc/jre.properties file.</details>
     <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dnsjava/${dnsjava-bundle-version}</bundle>
     <feature version='${project.version}'>camel-core</feature>
     <bundle>mvn:org.apache.camel/camel-dns/${project.version}</bundle>


[4/5] git commit: camel-jms reply manager should use AC classloader to avoid using current thread CL which may lead to CL issues in OSGi deployments.

Posted by da...@apache.org.
camel-jms reply manager should use AC classloader to avoid using current thread CL which may lead to CL issues in OSGi deployments.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5e8235a8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5e8235a8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5e8235a8

Branch: refs/heads/camel-2.11.x
Commit: 5e8235a80449e795484127ac89990dd7e7897eee
Parents: e118998
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 09:10:01 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 09:15:30 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/jms/JmsProducer.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5e8235a8/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
index ec93dd8..4bf5598 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
@@ -75,7 +75,16 @@ public class JmsProducer extends DefaultAsyncProducer {
                 if (started.get()) {
                     return;
                 }
+
+                // must use the classloader from the application context when creating reply manager,
+                // as it should inherit the classloader from app context and not the current which may be
+                // a different classloader
+                ClassLoader current = Thread.currentThread().getContextClassLoader();
+                ClassLoader ac = endpoint.getCamelContext().getApplicationContextClassLoader();
                 try {
+                    if (ac != null) {
+                        Thread.currentThread().setContextClassLoader(ac);
+                    }
                     // validate that replyToType and replyTo is configured accordingly
                     if (endpoint.getReplyToType() != null) {
                         // setting temporary with a fixed replyTo is not supported
@@ -96,6 +105,10 @@ public class JmsProducer extends DefaultAsyncProducer {
                     }
                 } catch (Exception e) {
                     throw new FailedToCreateProducerException(endpoint, e);
+                } finally {
+                    if (ac != null) {
+                        Thread.currentThread().setContextClassLoader(current);
+                    }
                 }
                 started.set(true);
             }


[2/5] git commit: camel-jms reply manager should use AC classloader to avoid using current thread CL which may lead to CL issues in OSGi deployments.

Posted by da...@apache.org.
camel-jms reply manager should use AC classloader to avoid using current thread CL which may lead to CL issues in OSGi deployments.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f0d6ce32
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f0d6ce32
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f0d6ce32

Branch: refs/heads/master
Commit: f0d6ce32f5bf505432ec612287e73064c1466ed5
Parents: 9beccf1f3
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 09:10:01 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 09:10:01 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/jms/JmsProducer.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f0d6ce32/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
index ec93dd8..4bf5598 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
@@ -75,7 +75,16 @@ public class JmsProducer extends DefaultAsyncProducer {
                 if (started.get()) {
                     return;
                 }
+
+                // must use the classloader from the application context when creating reply manager,
+                // as it should inherit the classloader from app context and not the current which may be
+                // a different classloader
+                ClassLoader current = Thread.currentThread().getContextClassLoader();
+                ClassLoader ac = endpoint.getCamelContext().getApplicationContextClassLoader();
                 try {
+                    if (ac != null) {
+                        Thread.currentThread().setContextClassLoader(ac);
+                    }
                     // validate that replyToType and replyTo is configured accordingly
                     if (endpoint.getReplyToType() != null) {
                         // setting temporary with a fixed replyTo is not supported
@@ -96,6 +105,10 @@ public class JmsProducer extends DefaultAsyncProducer {
                     }
                 } catch (Exception e) {
                     throw new FailedToCreateProducerException(endpoint, e);
+                } finally {
+                    if (ac != null) {
+                        Thread.currentThread().setContextClassLoader(current);
+                    }
                 }
                 started.set(true);
             }


[3/5] git commit: CAMEL-6463: camel-spring should add routes later to ensure spring dependency injection is fully done, to allow wiring in spring beans in RouteBuilder classes. Thanks to Daniel Cook for the solution.

Posted by da...@apache.org.
CAMEL-6463: camel-spring should add routes later to ensure spring dependency injection is fully done, to allow wiring in spring beans in RouteBuilder classes. Thanks to Daniel Cook for the solution.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/65170906
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/65170906
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/65170906

Branch: refs/heads/master
Commit: 65170906077b6d7af0c777200bff1385920f42d5
Parents: f0d6ce3
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 09:11:58 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 09:11:58 2013 +0200

----------------------------------------------------------------------
 .../blueprint/CamelContextFactoryBean.java      |  3 +-
 .../xml/AbstractCamelContextFactoryBean.java    | 37 +++++++++++++-------
 .../camel/spring/CamelContextFactoryBean.java   | 12 +++++++
 .../SpringCamelContextNoDependsOnTest.java      |  4 +--
 .../spring/config/SpringRouteNoFromTest.java    |  2 +-
 .../spring/config/SpringRouteNoOutputTest.java  |  2 +-
 .../spring/issues/MisspelledRouteRefTest.java   |  6 ++--
 7 files changed, 47 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/65170906/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
index 027cc83..1e71c62 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
@@ -167,7 +167,6 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
     @XmlTransient
     private boolean implicitId;
 
-
     public Class<BlueprintCamelContext> getObjectType() {
         return BlueprintCamelContext.class;
     }
@@ -297,6 +296,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
             // Ignore, if the EventAdmin package is not available, just don't use it
             LOG.debug("EventAdmin package is not available, just don't use it");
         }
+        // ensure routes is setup
+        setupRoutes();
     }
 
     public String getDependsOn() {

http://git-wip-us.apache.org/repos/asf/camel/blob/65170906/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index 9fb8d9e..df369a5 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlTransient;
@@ -111,6 +112,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
     private List<RoutesBuilder> builders = new ArrayList<RoutesBuilder>();
     @XmlTransient
     private ClassLoader contextClassLoaderOnStart;
+    @XmlTransient
+    private final AtomicBoolean routesSetupDone = new AtomicBoolean();
 
     public AbstractCamelContextFactoryBean() {
         // Keep track of the class loader for when we actually do start things up
@@ -269,22 +272,31 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
 
         // init stream caching strategy
         initStreamCachingStrategy();
+    }
 
-        // must init route refs before we prepare the routes below
-        initRouteRefs();
+    /**
+     * Setup all the routes which must be done prior starting {@link CamelContext}.
+     */
+    protected void setupRoutes() throws Exception {
+        if (routesSetupDone.compareAndSet(false, true)) {
+            LOG.debug("Setting up routes");
 
-        // do special preparation for some concepts such as interceptors and policies
-        // this is needed as JAXB does not build exactly the same model definition as Spring DSL would do
-        // using route builders. So we have here a little custom code to fix the JAXB gaps
-        prepareRoutes();
+            // must init route refs before we prepare the routes below
+            initRouteRefs();
 
-        // and add the routes
-        getContext().addRouteDefinitions(getRoutes());
+            // do special preparation for some concepts such as interceptors and policies
+            // this is needed as JAXB does not build exactly the same model definition as Spring DSL would do
+            // using route builders. So we have here a little custom code to fix the JAXB gaps
+            prepareRoutes();
 
-        LOG.debug("Found JAXB created routes: {}", getRoutes());
-        
-        findRouteBuilders();
-        installRoutes();
+            // and add the routes
+            getContext().addRouteDefinitions(getRoutes());
+
+            LOG.debug("Found JAXB created routes: {}", getRoutes());
+
+            findRouteBuilders();
+            installRoutes();
+        }
     }
 
     /**
@@ -485,6 +497,7 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
     protected abstract <S> S getBeanForType(Class<S> clazz);
 
     public void destroy() throws Exception {
+        routesSetupDone.set(false);
         getContext().stop();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/65170906/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
index b25b329..1ba3163 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
@@ -288,6 +288,15 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
 
         SpringCamelContext context = getContext(false);
         if (context != null) {
+            // we need to defer setting up routes until Spring has done all its dependency injection
+            // which is only guaranteed to be done when it emits the ContextRefreshedEvent event.
+            if (event instanceof ContextRefreshedEvent) {
+                try {
+                    setupRoutes();
+                } catch (Exception e) {
+                    throw wrapRuntimeCamelException(e);
+                }
+            }
             // let the spring camel context handle the events
             context.onApplicationEvent(event);
         } else {
@@ -297,6 +306,9 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
                 // now lets start the CamelContext so that all its possible
                 // dependencies are initialized
                 try {
+                    // we need to defer setting up routes until Spring has done all its dependency injection
+                    // which is only guaranteed to be done when it emits the ContextRefreshedEvent event.
+                    setupRoutes();
                     LOG.trace("Starting the context now");
                     getContext().start();
                 } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/camel/blob/65170906/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextNoDependsOnTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextNoDependsOnTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextNoDependsOnTest.java
index c277a5e..1da5c22 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextNoDependsOnTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringCamelContextNoDependsOnTest.java
@@ -37,11 +37,11 @@ public class SpringCamelContextNoDependsOnTest extends SpringTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        // in this example CamelContext is created first, then route builder, and then the depends on bean is last
+        // in this example the depends on bean is created first, and then the route builder, and CamelContext is started last.
         long time1 = context.getRegistry().lookupByNameAndType("myDependsOnBean", MyDependsOnBean.class).getTime();
         long time2 = context.getRegistry().lookupByNameAndType("myRouteBuilder", MyDependsOnRouteBuilder.class).getTime();
 
-        assertTrue("myDependsOnBean should NOT be created before myRouteBuilder", time1 > time2);
+        assertTrue("myDependsOnBean should be created before myRouteBuilder", time2 > time1);
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/65170906/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoFromTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoFromTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoFromTest.java
index 6a96595..b4fc035 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoFromTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoFromTest.java
@@ -41,7 +41,7 @@ public class SpringRouteNoFromTest extends SpringTestSupport {
             answer = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/SpringRouteNoFromTest.xml");
             fail("Should have thrown exception");
         } catch (Exception e) {
-            IllegalArgumentException iae = (IllegalArgumentException) e.getCause().getCause();
+            IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
             assertEquals("Route myRoute has no inputs: Route(myRoute)[[] -> [To[mock:result]]]", iae.getMessage());
             return null;
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/65170906/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoOutputTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoOutputTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoOutputTest.java
index f3e156f..4ff49a0 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoOutputTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/SpringRouteNoOutputTest.java
@@ -41,7 +41,7 @@ public class SpringRouteNoOutputTest extends SpringTestSupport {
             answer = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/SpringRouteNoOutputTest.xml");
             fail("Should have thrown exception");
         } catch (Exception e) {
-            IllegalArgumentException iae = (IllegalArgumentException) e.getCause().getCause();
+            IllegalArgumentException iae = (IllegalArgumentException) e.getCause();
             assertEquals("Route myRoute has no outputs: Route(myRoute)[[From[direct:start]] -> []]", iae.getMessage());
             return null;
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/65170906/components/camel-spring/src/test/java/org/apache/camel/spring/issues/MisspelledRouteRefTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/issues/MisspelledRouteRefTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/MisspelledRouteRefTest.java
index 12ea239..f38b936 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/issues/MisspelledRouteRefTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/issues/MisspelledRouteRefTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.spring.issues;
 
 import junit.framework.TestCase;
+import org.apache.camel.CamelException;
 import org.apache.camel.spring.Main;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,8 +38,9 @@ public class MisspelledRouteRefTest extends TestCase {
         } catch (Exception e) {
             //expected but want to see what it looks like...
             LOG.debug("Exception message : " + e.getMessage());
-            assertTrue("Get a wrong exception name", e.getMessage().indexOf("nested exception is org.apache.camel.CamelException: "
-                         + "Cannot find any routes with this RouteBuilder reference: RouteBuilderRef[xxxroute]") > 0);
+
+            CamelException cause = (CamelException) e.getCause();
+            assertEquals("Cannot find any routes with this RouteBuilder reference: RouteBuilderRef[xxxroute]", cause.getMessage());
         }
     }
 }


[5/5] git commit: camel-jms reply manager should use AC classloader to avoid using current thread CL which may lead to CL issues in OSGi deployments.

Posted by da...@apache.org.
camel-jms reply manager should use AC classloader to avoid using current thread CL which may lead to CL issues in OSGi deployments.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f0749e91
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f0749e91
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f0749e91

Branch: refs/heads/camel-2.10.x
Commit: f0749e913610b2880b5fa2acc4a14dd9143efdc8
Parents: ff5cf8b
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 09:10:01 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 09:15:46 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/jms/JmsProducer.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f0749e91/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
index 86905dd..421074e 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
@@ -75,7 +75,16 @@ public class JmsProducer extends DefaultAsyncProducer {
                 if (started.get()) {
                     return;
                 }
+
+                // must use the classloader from the application context when creating reply manager,
+                // as it should inherit the classloader from app context and not the current which may be
+                // a different classloader
+                ClassLoader current = Thread.currentThread().getContextClassLoader();
+                ClassLoader ac = endpoint.getCamelContext().getApplicationContextClassLoader();
                 try {
+                    if (ac != null) {
+                        Thread.currentThread().setContextClassLoader(ac);
+                    }
                     // validate that replyToType and replyTo is configured accordingly
                     if (endpoint.getReplyToType() != null) {
                         // setting temporary with a fixed replyTo is not supported
@@ -96,6 +105,10 @@ public class JmsProducer extends DefaultAsyncProducer {
                     }
                 } catch (Exception e) {
                     throw new FailedToCreateProducerException(endpoint, e);
+                } finally {
+                    if (ac != null) {
+                        Thread.currentThread().setContextClassLoader(current);
+                    }
                 }
                 started.set(true);
             }