Monday, March 30, 2009

Trick to customize war deployment on ServiceMix4 using PAX

Here is another very interesting trick that you can use to customize the war the deployment process on ServiceMix.

customize = in this context, this word means How can I add property or extend existing of a MANIFEST file

e.g. : The WAR to be deployed contains tlb files created under the folder WEB-INF/tags/form and WEB-INF/tags/jms. By default PAX will create a MANIFEST file containing the property Bundle-Classpath with :
  • WEB-INF/classes
  • all jars from WEB-INF/lib directory
but will not take care about your folders

Two possibilities are available to tell to PAX that it must include in the Bundle-Classpath your folders

1) Command + uri

This one consists in to pass the parameters as an uri like this :

install war:file:///d:/temp/activemq-web-console-5.2.0.war?Bundle-Classpath= ., WEB-INF/tags/form, WEB-INF/tags/jms&Webapp-Context= activemqweb

2) Create a file.bnd + command

Another interesting option is to provide as a file the location of the WAR and the properties that you want to add
  • Create a file called xxxx.bnd
  • Add in the file the following lines :
Bundle-Classpath=., WEB-INF/tags/form, WEB-INF/tags/jms
  • use in your favorite OSGI server (ServiceMix) the following command to install the WAR :
install war-i:file:///c:/temp/activemq-web-console-5.2.0.bnd


Alin Dreghiciu said...

After some struggling with deploying ActiveMQ as a war using Pax Web, Pax Web Extender and war: protocol handler it is everything boiling down to (in your example):

install war:file:///d:/temp/activemq-web-console-5.2.0.war?Webapp-Context= activemqweb

or directly from Maven Central Repository:

install war:mvn:org.apache.activemq/activemq-web-console/5.2.0/war?Webapp-Context=activemqweb

or of course, the way you explained with a local file containing instructions.

The only thing to mention is that you do not actually need to set the Bundle-ClassPath because war: protocol will calculate it correctly for you.

cmoulliard said...


Are you sure that it will calculate for us ? I have used the trick here because (as mentioned by Led), the files (xxxx.tag) located in the directory /WEB-INF/tags/form and jms were not included in the Bundle-Classpath during war deployment