(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.
- 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 HelloWorldImpl.java 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: http://servicemix.apache.org/hello-world-bc.html
- 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.
