Apache Camel + JBoss 5

The following summarizes how I got  Apache Camel 1.6.0 to work in JBoss 5.  Since I only used this to test some toy code that uses Camel, it is not necessarily the best or even a complete solution, but it may help someone out there.

The key issue to overcome is that Camel needs to find annotated classes in a given package (exactly which package is not relevant for this discussion).  It uses ClassLoader.getResources(String name) to get the URL(s) which specify the package.  Camel has a class, located at org.apache.camel.util.ResolverUtil that performs this function.  It “understands” standard URL formats, such as “jar:” and “file:”.   JBoss 5, however, seems to use its own “virtual file system” URL protocol to specify the locations of resources, which Camel does not understand.

For example, this is the URL that JBoss uses to identify the quartz-ra.rar file on my development system: (Note the vfszip protocol)


Upon attempting to use Camel, the following error is shown in the log:

WARN  [org.apache.camel.util.ResolverUtil] (main) Could not read entries in url: vfszip:/opt/jboss/jboss-5.0.0.GA/server/default/lib/camel-core-1.6.0.jar/org/apache/camel/converter/
java.io.FileNotFoundException: /opt/jboss/jboss-5.0.0.GA/server/default/lib/camel-core-1.6.0.jar/org/apache/camel/converter (Not a directory)

My solution was to create a JbossResolverUtil class that extends Camel’s ResolverUtil class, overriding its resource lookup implemention to use JBoss’s vfs library instead.

In order to configure Camel to use the JbossResolverUtil class, I also had to create two more classes which appropriately instantiate and use my replacement resolver.  JbossCamelContext extends org.apache.camel.impl.DefaultCamelContext, and JbossTypeConverter extends org.apache.camel.impl.converter.DefaultTypeConverter.

The code can be found at http://github.com/rhdev/example-camel-jboss/tree/master


Build with maven.  Note that the pom.xml uses the jboss repository so that maven can find the jboss-vfs jar:

mvn install

Copy the jar file to your JBoss deployment shared lib directory.  For example, in my environment, I use:

cp target/example-camel-jboss-1.0-SNAPSHOT.jar \


In your code, replace DefaultCamelContext with JbossCamelContext and make sure you include example-camel-jboss-1.0-SNAPSHOT.jar in your classpath:

import example.camel.jboss.JbossCamelContext;

CamelContext context = new JbossCamelContext();

That should be it.  If anyone knows of an easier way, please let me know.

2 comments so far

  1. Claus Ibsen on


    Nice findings. We plan to add SPI for pluggable resolvers in Camel 2.0.
    Just created a ticket for it based on your blog.


  2. […] 3, 2009 Filed under: Uncategorized | This is a followup to my previous post about how to get Apache Camel 1.6.0 to work using JBoss 5.  In this post, I provide some code to use configure Camel using Spring.  As with vanilla Camel, […]

Comments are closed.

%d bloggers like this: