Enterprise Integration Zone is brought to you in partnership with:

Independent IT Consultant and Apache Camel Committer with a background in open source Java architecture, design and development. Currently helping companies utilize Apache ActiveMQ, Camel & Servicemix technologies. Ben is a DZone MVB and is not an employee of DZone and has posted 11 posts at DZone. You can read more from them at their website. View Full User Profile

Apache ServiceMix Development Environment Setup

04.28.2012
| 13295 views |
  • submit to reddit
Here is a quick guide to setting up a development environment for working on Apache Servicemix projects... You can update some of these versions mentioned in the rundown, as it was written a little while ago.

Java 1.6

  • download the JDK and run installation
  • add the /jdk/bin directory to your system path
  • create JAVA_HOME environment variable pointing to the root JDK directory
Maven 2.1

  • download binary and unzip to a local directory
  • edit the /bin/mvn.bat file to increase the Maven heap size (MAVEN_OPTS=-Xmx512m)
  • add the /maven/bin directory to your system path
Eclipse 3.4

  • download Eclipse and run installation
  • open Eclipse

    • create a new workspace
    • create new project or import any existing projects 

  • setup m2eclipse plugin

    • go to Help->Software Updates->Available Software tab
    • then click 'Add Site' and add 'http://m2eclipse.sonatype.org/update/ and call it 'm2eclipse'
    • select the m2clipse components to install, click finish and restart Eclipse
    • go to Windows->Preferences->Maven->Installations
      • set the user settings to your maven settings.xml file
      • verify that this setup the M2_REPO variable to point to your local repo under Java->Build Path->Classpath Variables
    • go to Windows->Preferences->Maven->Archetypes
      • click 'Add Remote Catalog'
        • catalog file = http://repo.fusesource.com/maven2
        • name = Fuse Catalog
        • click OK
Fuse ESB 4.2 (aka ServiceMix)

  • donwload Fuse ESB 4.2 and run installation
basic development process

  • create a new project using an archetype (Maven template) that best matches your application needs

    • from Eclipse
      • File->New->Maven->Maven Project
      • check 'use default workspace location' and click next
      • choose the 'Fuse Catalog' and enter a desire filter
      • choose an archetype
      • click next
      • enter a group id of 'com.<company>.<project>'
      • enter an artifact of '<component>'
      • enter a package name of 'com.<company>.<project>.<component>'
      • click finish 
        • note: I have seen issues with some archetypes in Eclipse, if this happens, use the command line approach instead
    • from command line
      • mvn archetype:create
        -DarchetypeGroupId=org.apache.servicemix.tooling
        -DarchetypeArtifactId=servicemix-osgi-camel-archetype
        -DarchetypeVersion=2010.01.0-fuse-01-00
        -DremoteRepositories=http://repo.fusesource.com/maven2
        -DgroupId=com.mycompany.project1
        -DartifactId=component1
        -Dversion=0.0.1-SNAPSHOT
  •  build the project

    • in Eclipse
      • right click on the project, go to Run As->Maven install
    • from command line
      • run 'mvn install'
    • project JAR will be created under the /target directory and deployed it to your local Maven repository
  • deploying the project to Fuse ESB 4.2

    • run /<smx>/bin/servicemix to start the server
    • make sure any required features/bundles have been installed
      • activemq, camel, etc
    • from the karaf console, install your project bundle
      • osgi:install -s mvn:com.mycompany.project1/component1
    • assuming that worked, you now have a working project
  • customize project and repeat build/deploy process

Monitoring


  • watch the servicemix log file
    • tail -f /<smx>/data/log/karaf.log
  •  JConsole
    • <jdk>/bin/jconsole.exe
    • provides remote/local JVM monitoring
    • remote connection uri = service:jmx:rmi:///jndi/rmi://:1099/jmxrmi
    • default user/password = karaf/karaf
  • VisualVM
    • <jdk>/bin/jvisualvm.exe
    • provides remote/local JVM monitoring (slightly better than JConsole)
other recommended software (for Windows)

  • cygwin  - adds basic Linux command support for Windows
  • PowerCMD - tabbed command prompts...trial/not free
  • kdiff3 - excellent file/directory comparison tool
  • SoapUI - for testing HTTP endpoints

If you know of other configurations or tools that are relevant, let me know...
Published at DZone with permission of Ben O' Day, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)