Upgrade your Brain

Getting started with ServiceMix 4.2 and WebServices (with Maven and Eclipse on Windows)

(Under this post I noted down some great resources for getting started, so if you’re searching for those, have a look at the bottom of this article)

Okay, I had a really hard time getting started with ServiceMix, as there’re so many technologies involved and I knew none of them. Maven. OSGi. ServiceMix. Karaf. Most of the time, you only want something to work so you can apply the same or nearly the same technique again, right? So here’s a little plan what works and where you can start your journey:

Install maven. Install Eclipse.

Install the m2 plugin for eclipse.

Download ServiceMix 4.2.

– Open a windows command terminal. Navigate to %servicemix_home%/bin

– “servicemix.bat” starts ServiceMix. You get into the Karaf console. Typing TAB and “y” shows you a lot of commands you can try out. (If you want, try some … easy administration!)

– Open Eclipse. Seriously. Import –> Maven project

– In the wizard, browse to %servicemix_home%/examples

– Pick the “cfx-osgi” folder and use the pom.xml the wizard finds there for importing the project. Finish the wizard.

– Change the sourcecode of the file to do what you want and save that file.

– Right click the project –> Run –> Maven install. A .jar file gets generated.

– Copy that jar file into the %servicemix_home%/deploy folder.

– Get back to Eclipse … there’s a client.html file in the imported project. Right click that –> Open With –> Web Browser

– Click the “send” button. Smile.

– (Optional: Now remove the .jar file from the deploy folder of servicemix. Click the “send” button on the HTML form again. Smile.)

If you want to learn more, you can look into the FUSE ServiceMix documentation (FUSE is documenting and selling support for ServiceMix, but they don’t put much more on top of ServiceMix, so the documentation is pretty good). Or try the text files that come with the examples.

Hope this helped you a bit.

Edits and Updates:

  • I found this tutorial VERY helpful dealing with and understanding BCs:
  • And as you will be using Spring anyways and there’s no way around it, just to understand how simple it works, begin with this small tutorial: Getting started with Spring
  • FUSE is a trademark that’s selling support for servicemix and label servicemix as “FUSE”. No matter if I got that right, FUSE is basically just ServiceMix. As the FUSE people are apt writing nice documentation (and the ServiceMix-page documentation basically sucks), you should head over to FUSE and read their docs (click on documentation and see a lot of nice PDFs). They explain everything you need in a well-written way – OSGi, Spring, Karaf, Maven, CXF, …
  • If you want to use Eclispe and Maven to build OSGi bundles, read this page calmly. It explains how you configure all the OSGi stuff in the pom.xml. Additionally, don’t try to use Eclipse’s plugin-development features as this will mess with your dependency resolution. Maven seems to say: put everything into my hands and you’ll be fine (even if you don’t like me).
  • This is a neat wiki article for getting started with building OSGi bundles for ServiceMix from Eclipse.
  • Here’s a nice article and tutorial explaining how to develop OSGi Bundles with Eclipse.

19 thoughts on “Getting started with ServiceMix 4.2 and WebServices (with Maven and Eclipse on Windows)

  1. As succinct as your post : Thanks !

    While we’re at it, i’m wondering if the fusesource bundle is woth it or just plain ServiceMix … Any thoughts ?

  2. I’m not using the FuseSource bundle, but the usual ServiceMix 4.2. But I guess the FuseSource bundle won’t perform worse.

  3. Hi! Thanks for the tutorial. :)

    I’m having a problem. When i press “send”, after opening the html within eclipse, i get an error saying “error opening”. If i press “send” with the html opened in my browser, the text box in the right is filled with “STATUS: 0”

    What’s wrong???


  4. i skipped a step in the process. Still, now i have cxf-osgi-4.2.0.jar and i copied it to deploy directory. Same error as before…

  5. There could be all kinds of problems, ServiceMix not running properly, Maven not setup correctly, wrong versions of .jars … sorry,man, but that’s not a problem I can debug without sitting on your system.

    Copying the cxf-osgi.jar into the deploy directory is usually not necessary. Did you import the example into eclipse and did the maven –> install? And then copy that file into the deploy folder? In other words: did you do what is written above?

  6. so, let me show you all the process :)

    importing the project:

    this is the file tree i get, in eclipse:

    so, after selecting “Maven install”, i get this output in the console:

    [INFO] Scanning for projects…
    [WARNING] Some problems were encountered while building the effective model for

    [WARNING] ‘build.pluginManagement.plugins.plugin.(groupId:artifactId)’ must be

    unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-

    surefire-plugin @ org.apache.servicemix.features:features:4.2.0, C:\Users


    \4.2.0\features-4.2.0.pom, line 685, column 23
    [WARNING] ‘build.plugins.plugin.version’ for org.codehaus.mojo:exec-maven-plugin

    is missing. @ line 79, column 21
    [WARNING] The expression ${pom.artifactId} is deprecated. Please use

    ${project.artifactId} instead.
    [WARNING] ‘repositories.repository.layout’ for uses the unsupported

    value ‘legacy’, artifact resolution might fail. @

    org.apache.servicemix.features:features:4.2.0, C:\Users


    \4.2.0\features-4.2.0.pom, line 319, column 19
    [WARNING] It is highly recommended to fix these problems because they threaten

    the stability of your build.
    [WARNING] For this reason, future Maven versions might no longer support building

    such malformed projects.
    [INFO] ————————————————————————
    [INFO] Building Apache ServiceMix Example :: CXF OSGi 4.2.0
    [INFO] ————————————————————————

    [INFO] — maven-dependency-plugin:2.1:copy (copy-legal) @ cxf-osgi —
    [INFO] Configured Artifact:
    [INFO] Copying legal-1.0.xml to C:\Users\dead_devil_66\Documents\apache-

    [INFO] — maven-remote-resources-plugin:1.1:process (default) @ cxf-osgi —
    [INFO] Setting property: classpath.resource.loader.class =>

    [INFO] Setting property: velocimacro.messages.on => ‘false’.
    [INFO] Setting property: resource.loader => ‘classpath’.
    [INFO] Setting property: resource.manager.logwhenfound => ‘false’.
    [INFO] — maven-resources-plugin:2.3:resources (default-resources) @ cxf-osgi

    [INFO] Using ‘UTF-8’ encoding to copy filtered resources.
    [INFO] Copying 2 resources
    [INFO] Copying 3 resources
    [INFO] — maven-compiler-plugin:2.0.2:compile (default-compile) @ cxf-osgi —
    [INFO] Compiling 3 source files to C:\Users\dead_devil_66\Documents\apache-

    [INFO] — maven-resources-plugin:2.3:testResources (default-testResources) @

    cxf-osgi —
    [INFO] Using ‘UTF-8’ encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory C:\Users\dead_devil_66\Documents

    [INFO] Copying 3 resources
    [INFO] — maven-compiler-plugin:2.0.2:testCompile (default-testCompile) @ cxf-

    osgi —
    [INFO] No sources to compile
    [INFO] — maven-surefire-plugin:2.3.1:test (default-test) @ cxf-osgi —
    [INFO] Surefire report directory: C:\Users\dead_devil_66\Documents\apache-


    T E S T S
    There are no tests to run.

    Results :

    Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

    [INFO] — maven-bundle-plugin:2.0.1:bundle (default-bundle) @ cxf-osgi —
    [INFO] — maven-install-plugin:2.2:install (default-install) @ cxf-osgi —
    [INFO] Installing C:\Users\dead_devil_66\Documents\apache-servicemix-

    4.2.0\examples\cxf-osgi\target\cxf-osgi-4.2.0.jar to C:\Users


    [INFO] Installing C:\Users\dead_devil_66\Documents\apache-servicemix-

    4.2.0\examples\cxf-osgi\pom.xml to C:\Users\dead_devil_66\.m2\repository\org

    [INFO] — maven-bundle-plugin:2.0.1:install (default-install) @ cxf-osgi —
    [INFO] Parsing file:/C:/Users/dead_devil_66/.m2/repository/repository.xml
    [INFO] Installing org/apache/servicemix/examples/cxf-osgi/4.2.0/cxf-osgi-

    [INFO] Writing OBR metadata
    [INFO] ————————————————————————
    [INFO] ————————————————————————
    [INFO] Total time: 19.019s
    [INFO] Finished at: Wed Jan 19 18:30:45 GMT 2011
    [INFO] Final Memory: 11M/28M
    [INFO] ————————————————————————

    a pic of the location of the jar and the deploy dir, after copying the jar:

    and this is the final result…..

  7. No .jars that you drop into the deploy folder get automatically installed. After you have installed the .jar in your maven repository, you must either install it in servicemix via a command in Karaf or you have to copy the .jar from your Maven Repository (under users/yourname/.m2/repository/… ) into the deploy folder. I didn’t mention the path in the post above, maybe that’s what was misleading.

    If that doesn’t work, please take a look into the servicemix/examples/cfx-osgi folder. There’s a readme.txt or something similar in it. Make sure that this example works for you first – otherwise some part might be broken.

    Trying out the maven eclipse plugin today I saw that it was broken by a recent update on my machine … maybe you have the same problem if you get build failure when installing via maven.

  8. well, if i follow the example in the readme file, seems i can get the wsdl.

    Thanks for the help :)

  9. Hey Tim,
    Sorry to abuse this comments thread but i have a little question :
    Which example on servicemix do you thing is nearest to this scenario :
    A remote web service (i have its wsdl) that i’d like to “proxy” on servicemix, or use into some kind of camel route ?

  10. Hi,

    Thanks for this tutorial :)

    in fact i want to run SMX 4.2 under jbossAs 5, what you assume: deploy servicemix as JBI components or OSGI bundles. and how i can do this?


  11. Hi, thanks for this tutorial but i’m having a problem when import a project to eclipse workspace, the following error with the pom seems to persist. Please help

    Project build error: Non-resolvable parent POM for org.apache.servicemix.examples:examples:4.2.0-fuse-02-00: Failure to transfer org.apache.servicemix.features:features:pom:4.2.0-fuse-02-00 from was cached in the local repository, resolution will not be reattempted until the update interval of fusesource.m2 has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.servicemix.features:features:pom:4.2.0-fuse-02-00 from/to fusesource.m2 ( Connect times out and ‘parent.relativePath’ points at wrong local POM

  12. Hi Tim,
    Thank you for the article. This is a good start. I am able to import the files without issue but I am getting different error.

    org.apache.hello_world_soap_http.Greeter is missing in the project and maven dependencies is not able to resolve this.

    Did all the projects got resolved automatically for you.
    Is the maven lifecycle is not showing any conflict for you.

    Thank you for the help

  13. Thanks Tim for the Post.
    The folks reading the post, some of my comments may help.

    Servicemix 4.2 is based on JDK 6. Dont use JDK 7. you may face errors while starting the Servicemix

    M2E new version gives error about the lifecycle. go ignore the plugins then and update configurations.Lot of post shows adding the plugin management but the pom.xml has parents which makes it very difficult to introduce ignore goals. Put some time it will compile.

    You have to work on the project to correct the JRE library dependency.
    Rest follow the blog, and the readme text in the project.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top