-
1. Re: Camel-velocity in OSGi
tpurcell Feb 12, 2009 12:39 PM (in response to tpurcell)Okay
I think I figured this out. My questions(and answers):
Am I missing something?
No
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?
Yes.
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/1.5.1.0-fuse/camel-velocity-1.5.1.0-fuse.jar
Thanks
Tom
-
2. Re: Camel-velocity in OSGi
gertv Feb 12, 2009 2:43 PM (in response to tpurcell)Tom,
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
features/addUrl mvn:org.apache.servicemix.camel/org.apache.servicemix.camel.features/4.0-m2-SNAPSHOT/xml/features
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,
Gert Vanthienen
-
3. Re: Camel-velocity in OSGi
tpurcell Feb 12, 2009 4:15 PM (in response to tpurcell)Well
My previous post got me up to deploy but at runtime (when a message actually hit the component) I got this:
servicemix> *******************************************************************
Starting Apache Velocity v1.5 (compiled: 2007-02-22 08:52:29)
Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties
Trying to use logger class org.apache.velocity.runtime.log.SimpleLog4JLogSystem
Couldn't find class org.apache.velocity.runtime.log.SimpleLog4JLogSystem or necessary supporting classes in classpath.
org/apache/log4j/Layout
java.lang.NoClassDefFoundError: org/apache/log4j/Layout
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
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
-
4. Re: Camel-velocity in OSGi
tpurcell Feb 12, 2009 4:40 PM (in response to tpurcell)Okay
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?
Thanks
Tom
-
5. Re: Camel-velocity in OSGi
davsclaus Feb 13, 2009 10:33 AM (in response to tpurcell)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.
-
6. Re: Camel-velocity in OSGi
tpurcell Feb 13, 2009 11:14 AM (in response to davsclaus)Claus
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
Tom
-
7. Re: Camel-velocity in OSGi
tpurcell Feb 13, 2009 12:07 PM (in response to gertv)Gert
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 4.0.0.3). This is what happened:
servicemix> features addUrl mvn:org.apache.servicemix.camel/org.apache.servicemix.camel.features/4.0.0.3-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)
at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1725)
at org.apache.felix.framework.Felix._startBundle(Felix.java:1588)
...
So I went to:
$HOME/.m2/repository/org/apache/servicemix/camel/org.apache.servicemix.camel.features/4.0.0.3-fuse/org.apache.servicemix.camel.features-4.0.0.3-fuse-features.xml
I opened "org.apache.servicemix.camel.features-4.0.0.3-fuse-features.xml" and added the following line to the camel-velocity stanza:
I reentered the features comman and everything deployed.
Thanks
Tom
Edited by: tpurcell on Feb 13, 2009 5:01 PM
Edited by: tpurcell on Feb 13, 2009 5:05 PM
-
8. Re: Camel-velocity in OSGi
davsclaus Feb 14, 2009 4:07 AM (in response to tpurcell)Hi
I have backported the fix into Camel 1.x, will be in the next FUSE release out next month.
Camel velocity is documented here:
http://camel.apache.org/velocity.html
However we usually only document the endpoint URI options, but the component itself can also be configured. Check the javadoc or the source:
http://camel.apache.org/maven/camel-velocity/apidocs/index.html
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.