Apache Camel + JBoss 5 + Spring

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, you cannot do this with JBoss 5 due to the fact that Camel’s ResolverUtil does not understand JBoss’s “virtual file system”.

Please note Claus Ibsen’s comment in my original post that he plans to allow the ResolverUtil to be configurable in Apache Camel 2.0.  In the meantime, you can refer to code I have provided at GitHub, which is based on camel-osgi.

As before, a pom.xml file is provided to build the jar.  Place the jar file in your JBoss 5 installation’s server/[config]/lib directory.

In your spring xml, be sure to use the new namespace that I have defined for Camel + JBoss 5 when you define your camelContext.  For example:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://example.org/camel/schema/jboss http://example.org/camel/schema/jboss/camel-jboss.xsd
       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

  <jboss:camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
      <from uri="imaps://imap.gmail.com?username=[yourusername]&amp;password=[yourpassword]&amp;
      <to uri="log:example.camel?level=DEBUG"/>

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.