I think I figured this out. My questions(and answers):
Am I missing something?
If not which version of velocity should I be looking for?
This was easy. Its in the pom for camel-velocity. The version of velocity required is 1.5.
Is there a repo where I can download all the required bundles?
The people at SpringSource have packaged a bunch of jars as OSGi bundles and made them available. You can search the repo for what you need at: http://www.springsource.com/repository/app/
Add to your pom the dependancy for their OSGi version of the pom and a reference to their repository. When you build your bundle maven will pull down the OSGi-ified jar as well as its dependencies.
Or do I have to run bnd against all of them?
Yes, if you cannot find it at the above website.
The following are the bundles I had to install to use camel-velocity:
JDOM DOM Processor (1.0.0): /org/jdom/com.springsource.org.jdom/1.0.0/com.springsource.org.jdom-1.0.0.jar
Apache Commons Collections (3.2.0): /org/apache/commons/com.springsource.org.apache.commons.collections/3.2.0/com.springsource.org.apache.commons.collections-3.2.0.jar
Apache Commons Lang (2.1.0): /org/apache/commons/com.springsource.org.apache.commons.lang/2.1.0/com.springsource.org.apache.commons.lang-2.1.0.jar
Apache Velocity Engine (1.5.0): /org/apache/velocity/com.springsource.org.apache.velocity/1.5.0/com.springsource.org.apache.velocity-1.5.0.jar
camel-velocity (1.5.1.fuse): /org/apache/camel/camel-velocity/18.104.22.168-fuse/camel-velocity-22.214.171.124-fuse.jar
We actually have an easier solution for deploying Camel bundles in ServiceMix Kernel. There's a features descriptor available for deploying these bundles.
You first have to add the features url with
Once that is done, you can just install any Camel component using
features/install camel-xxx (e.g. features/install camel-velocity)
Now, I also have to admit that we are currently facing a bug with this thing -- the Maven plugin that generates the features.xml file sometimes generates bundles in the correct order. We're hoping to get https://issues.apache.org/activemq/browse/SMX4-215 fixed tomorrow so we have clean SNAPSHOTs again after the weekend. Until then, you can just go and change the order of the bundles in your local repository copy -- all the required should be in the feature, it's just the order that's wrong.
Sorry for the temporary inconvenience and hope this helps,
My previous post got me up to deploy but at runtime (when a message actually hit the component) I got this:
at java.lang.Class.forName0(Native Method)
I went back to the Spring OSGi repo and added their log4j to my pom. I rebuilt and deployed the Spring OSGi bundle and that error disappeared. So add the following to required bundles:
Apache Log4J (1.2.15): /org/apache/log4j/com.springsource.org.apache.log4j/1.2.15/com.springsource.org.apache.log4j-1.2.15.jar
I'm still not out of the woods. My bundle now deploys and it runs successfully but I get the following messages on the OSGi console:
servicemix> \[camel.sqs.SQSComponent@cb8a0c8\] VelocityEndpoint INFO LogSystem has been deprecated. Please use a LogChute implementation.
\[camel.sqs.SQSComponent@cb8a0c8\] VelocityEndpoint INFO FileResourceLoader : adding path '.'
Since things work and both messages are of typeINFO I can probably ignore this but in production I'd rather have only really important messages display so I'd like to get rid of them.
On the first, it seems I could get rid of this by specifying the Velocity runtime.log.logsystem.log4j.logger property but I'm not sure how to set runtime properties on the Velocity engine instantiated by camel. Any suggestions?
On the second, I don't know why its complaining. It found the template and processed it properly. Again, any suggestions?
Do you really get a INFO logging at each processing? Not just the first one?
Well in Camel 2.0 I have fixed to use non @deprecated API in camel-velocity. I guess I should backport it into Camel 1.x as well.
You're right. I've been nursing my process along(code, deploy, one test, a little more code, deploy, one more test,...) So I was getting the messages every time I ran but then I was redeploying every time I ran.
So the error appears on processing the first message after a deploy. It does not come out on subsequent messages (unless you redeploy).
The question remains, however, is it possible to set runtime properties on the Velocity engine?
Thanks for the tip. I uninstalled the bundles I listed in the earlier mails. Then I executed the commands on the OSGI console (I'm running fuse 126.96.36.199). This is what happened:
servicemix> features addUrl mvn:org.apache.servicemix.camel/org.apache.servicemix.camel.features/188.8.131.52-fuse/xml/features
servicemix> features install camel-velocity
ERROR BundleException: Unresolved constraint in bundle 199: package; (package=org.apache.tools.ant.taskdefs)
Over in the log I got:
11:37:08,600 | DEBUG | Thread-40 | FeaturesServiceImpl | res.internal.FeaturesServiceImpl 191 | found installed bundle: org.apache.servicemix.bundles.velocity 199
11:37:08,601 | DEBUG | Thread-16 | JLineConsole | .geronimo.gshell.console.Console 132 | Work failed: org.osgi.framework.BundleException: Unresolved constraint in bundle 199: package; (package=org.apache.tools.ant.taskdefs)
org.osgi.framework.BundleException: Unresolved constraint in bundle 199: package; (package=org.apache.tools.ant.taskdefs)
So I went to:
I opened "org.apache.servicemix.camel.features-184.108.40.206-fuse-features.xml" and added the following line to the camel-velocity stanza:
I reentered the features comman and everything deployed.
Edited by: tpurcell on Feb 13, 2009 5:01 PM
Edited by: tpurcell on Feb 13, 2009 5:05 PM
I have backported the fix into Camel 1.x, will be in the next FUSE release out next month.
Camel velocity is documented here:
However we usually only document the endpoint URI options, but the component itself can also be configured. Check the javadoc or the source:
On the component you can set a VelocityEngine. This engine you can configure yourself and set the runtime parameters of choice
Check the source code in VeloictyEndpoint to see how you can create a new engine and set the logger options.