servicemix-camel classloader problem
rmayo Jul 15, 2009 4:46 PMHi,
I believe I've discovered a bug in the servicemix-camel component.
I am using a camel SU deployed in servicemix (v3.3.1.15-fuse) to coordinate the routing between the various service units in my service assembly. My camel router receives exchanges from a jbi endpoint and then uses the pipeline pattern to pass the exchange to other jbi endpoints which process/transform the exchange along the way.
When my camel RouteBuilder recieves a message exchange, the initial classloader is the SU classloader as I would expect (contains all the jars bundled in the lib directory of my camel SU). BUT, after sending an exchange to another jbi:endpoint, the context classloader is now set to the Camel Component and NOT the SU classloader - which means the jars bundled in the SU lib are no longer available.
For example:
public class MyRouteBuilder extends RouteBuilder {
public class PrintClassLoader implements Processor {
public void process(Exchange exchange) throws Exception {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
System.out.println("ClassLoader: " + cl);
}
}
public void configure() {
// receives a message to a JBI endpoint...
from("jbi:endpoint:urn:foo:bar:MyService:MyEndpoint")
.process(new PrintClassLoader()) // this will be the SU classloader "camel-context"
.to(jbi:endpoint:urn:foo:bar:MyService:MyOtherEndpoint")
.process(new PrintClassLoader()) // this will be the Component classloader
}
}
I noticed this because in my router, I have a Processor which ultimately uses hibernate to access the database. Since the processor is invoked after routing the exchange to another JBI endpoint, the hibernate jars are no longer available.
I would think that using Camel to coordinate routing between jbi endpoints is a typical scenario when using ServiceMix (no?), but I haven't seen this issue reported on any of the forums so far. Am I doing something wrong?
Any help would be greatly appreciated.
Thanks.
-Ryan