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 <davscl...@apache.org> Authored: Tue Jul 23 09:10:01 2013 +0200 Committer: Claus Ibsen <davscl...@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); }