Tuesday, December 22, 2009

ServiceMix 3.3.1 Basic Sample Build fails - How to fix

I've been learning ServiceMix 3.3.1 for some stuff at work lately. I've also had to learn Maven as ServiceMix uses it for many things as well. I started like most people by following the Getting Started guide and trying the wsdl-first sample which worked quite well right off the bat. However when I went to try to work thru the basic example, I ran into a failure right away.

I chose the .../examples/basic sample to work on next based on it's name. I needed the next simple example to help me learn. While it is basic in terms that there is no source code for any custom service units or engines, there is an assembly which is defined in the servicemix.xml config file. It is not basic in the sense that you need to understand that it's a static deployment of components, it starts up a servicemix instance when it's run, etc.

So finding that the basic example is not so basic to understand, I tried to run it for the first time hoping that it's output would help enlighten me. Alas it failed with lots of output.

On a side note, I am running OS X Snow Leopard (10.6.2) with JDK 1.6.0_17, Maven 2.2.1 and ServiceMix 3.3.1 which I got as a download binary. But this issue is going to hit anyone trying the basic sample with 3.3.1.

The Problem
When I tried to build the apache-servicemix-3.3.1/examples/basic sample, I got the following error output (truncated for brevity):
 mvn jbi:embeddedServicemix
[INFO] Scanning for projects...
[INFO] snapshot org.apache.servicemix:samples:3.3.1-SNAPSHOT: checking for updates from apache.snapshots
Downloading: http://people.apache.org/repo/m2-snapshot-repository/org/apache/servicemix/samples/3.3.1-SNAPSHOT/samples-3.3.1-SNAPSHOT.pom
[INFO] Unable to find resource 'org.apache.servicemix:samples:pom:3.3.1-SNAPSHOT' in repository apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository)
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
...

I looked in the forums and mailing list archives for ServiceMix and at many Google hits related to ServiceMix and build issues. I even posted a question to the ICQ. But no answer was to be found or had. After looking at many JIRA issues, other peoples issues, etc., I finally found a little blurb online that helped me figure it out. It took awhile because nothing talked about the basic example. The blurb I did find was about someone else's problem building something else. But it was enough that it helped me figure out what was wrong with mine and it showed me yet again that it's oftentimes a super simple thing.

The Fix
The fix is actually quite simple and had I had more experience with Maven it might have jumped out to me right away. In the pom.xml file in the base director of the basic example, I had to change the following code at the very top of the pom.xml file:
<parent>
<groupId>org.apache.servicemix</groupId>
<artifactId>samples</artifactId>
<version>3.3.1-SNAPSHOT</version>
</parent>

to be:
<parent>
<groupId>org.apache.servicemix</groupId>
<artifactId>samples</artifactId>
<version>3.3.1</version>
</parent>

The only change being the removal of the text -SNAPSHOT from the version tag value. After I removed that and saved the pom.xml file, I was ready to try the build again.

Build it & Run it -- Success???
I typed the following at the command line (as stated in the README.txt file in the basic sample dir):

mvn jbi:embeddedServicemix

The build continued along fine and then automatically started servicemix. Wahoo! In my terminal I saw ServiceMix start outputting text like the following and continue doing it every few seconds:
 2009-12-23 01:21:49,961 [.trace-thread-3] INFO TraceComponent         - Exchange: InOnly[
id: ID:192.168.2.2-125ba69625e-13:1
status: Active
role: provider
service: {http://servicemix.apache.org/demo/}trace
endpoint: trace
in: <?xml version="1.0" encoding="UTF-8"?><timer><name>My Example Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example Job</fullname><description/><fireTime>Wed Dec 23 01:21:49 CST 2009</fireTime></timer>
] received IN message: org.apache.servicemix.jbi.messaging.NormalizedMessageImpl@15a08be5{properties: {}}
2009-12-23 01:21:49,961 [.trace-thread-3] INFO TraceComponent - Body is: <?xml version="1.0" encoding="UTF-8"?><timer><name>My Example Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example Job</fullname><description/><fireTime>Wed Dec 23 01:21:49 CST 2009</fireTime></timer>
I had it working.

After the sidetrack to learn some Maven and searching the net, I'm finally back to trying to understand what a static deployment means in ServiceMix, etc.

I hope this helps someone who's beginning with ServiceMix.


2 comments:

Unknown said...

Thank you for sharing your fix and saving time for others!

Deepika Gangula said...

Thanks, the post helped me for another example and saved me time...