Wednesday, 6 July 2011

Using NetBeans 7.0 to create an Apache Camel project without Spring dependency

NOTE: This article was rewritten to fix the issue of unable to create a new project based on the apache camel quickstart archetype.

Despite the conveniences offered by the Spring Framework, there are times I would rather live without it, especially for simple applications that I need to keep as lightweight as possible. To do this, the steps are below:

1) Create a new Project in NetBeans 7.0, and choose Maven -> Java Application, and click Next.

2) In Step 2 of Project Wizard, enter your project name, and amend the other settings such as Project Location, Group Id, as you deemed fit.

Once done, click Finish, and wait for the Project setup to be completed.

3) Expand your Project from the Project Tab, right-click on Dependencies folder  and select Add Dependency...

4) In the Add Dependency dialog box, enter camel-core in the Query textbox under the Search tab. Once the Search Results appear, expand org.apache.camel: camel-core folder and click on the version you require, or the latest version available (currently latest is version 2.8.0) [bundle]. Central or Local should not matter, as you should only have Local if you have downloaded it before (either directly in your project or indirectly in other projects with camel-core dependency).

     Click on the Add button.

5) Now expand the Source Packages in your project and you should be able to find Modify the main class to the code below:

    public static void main( String[] args ) throws Exception
        CamelContext context = new DefaultCamelContext();

        // add our route to the CamelContext
        context.addRoutes(new RouteBuilder() {
            public void configure() {
                        when(xpath("/person/city = 'London'")).to("file:target/messages/uk").

        // start the route and let it do its work
        // stop the CamelContext

    You will need to add the necessary dependencies.

6) You can now run the application, which will read any files in your src/data folder, and parse the xml, and move the file to either the target/messages/uk or target/messages/others folder depending on whether the person -> city node contains the value 'London' or not.

    If you followed my previous blog entry 'Using NetBeans 7.0 to create a new project using Apache Camel', you should have sample message1.xml and message2.xml under your src/data folder, which you can use for testing purposes.

All folders here are relative to your project folder. Until my next blog, Good Luck and Good Bye!


  1. Thanks for these posts on Camel in Netbeans. All of the Camel related IDE posts I can find elsewhere have to do with Fuse, a proprietary solution. It's good to read about open source solutions.

  2. I'm glad that you like the article, duggram. Not that I have any issues with Fuse, which I believe will most probably makes things much simpler. But I dug into NetBeans because I want to find out how things works before moving on to higher level. Give me stronger foundation and better view of the platform I am using.

    But I have to admit I am not very active on Camel recently. I am now more on Web development work and am now playing around with Django, which is a Python framework. Quite impressed that the Python language is so much less noisy compared to Java, yet at the same time still quite explicit compared to Ruby.

    Live is a learning process ... I have to agree with that saying.

  3. This blog helped me a lot for understanding Camel.
    If possible can you please tell me how to integrate Camel with CXF and ActiveMQ.
    I searched but I could get only Maven dependencies.
    It would be of great help if you tell me how create those.
    Many Thanks

  4. Hi Sravanthi,

    What do you want to learn about integrating Camel with CXF and ActiveMQ? As for me, to learn about integrating a component, what I typically do to is to search for the component in Apache Camel's component page: Here are the URLs for the two Apache Camel components:


    Once you have browsed into those pages you will be able to see that to integrate with cxf, use Add Dependency option in the sub-menu of the Dependencies folder in your project, and enter: camel-cxf in the Query field. You can then select the appropriate version.

    For activemq, search for the following: activemq-camel in the Query field of the Add Dependency panel. You might also need to add dependency for: camel-jms

    Hope this helps.