Follow @cmoulliard
This week, I have discovered the web possibilities offered by the ServiceMix 4 platform. SMX ("pour les intimes") uses as its core platform the excellent packages of the project PAX which is the umbrella project for all OSGi bundles and tools.
In standard, the following bundles are installed :
[ 9] [Active ] [ ] [ 8] OPS4J Pax Logging - API (1.3.0)
[ 10] [Active ] [ ] [ 8] OPS4J Pax Logging - Service (1.3.0)
[ 11] [Active ] [ ] [ 5] OPS4J Pax Url - wrap: (0.3.3)
[ 12] [Active ] [ ] [ 5] OPS4J Pax Url - mvn: (0.3.3)
They are used to log information of the server and to install or wrap bundles. Nevertheless, PAX project is not limited to the mentioned bundles but proposes also Web support for jetty.
To install or transform ServiceMix as a Web Application Server, you can use the "web" and "web-core" feature (available under ServiceMix 4) or install the following bundles manually :
- OPS4J Pax Web - Web Container (0.5.2)
- OPS4J Pax Web - Jsp Support (0.5.2)
- OPS4J Pax Web Extender - WAR (0.5.0)
- OPS4J Pax Web Extender - Whiteboard (0.5.0)
- OPS4J Pax Url - war:, war-i: (0.3.3)
- Apache ServiceMix Bundles: jetty-6.1.14 (6.1.14.1)
The Web Application Server becomes available at the url http://localhost:8080.
Evidently, no jsp pages, servlets are available. Don't worry, to deploy a WAR, you only have to copy it to the deploy directory of ServiceMix and it will convert be converted as a bundle
By example, you can install a simple Hello World war using the command
install war:file:///d:/temp/sample.war?Webapp-Context=sample
remarks :
- file:/// must be changed according to the location of your war
- The parameter WebApp-Context is added to have a nicer web address
and see the result at the address : http://localhost:8080/sample/index.html
Yes, this looks beautiful but the web port number is 8080, my boss would like to secure the web site, change the session timeout, ....
This is very simple to do, you create a file named (org.ops4j.pax.web.cfg) and copy it in the directory etc of servicemix, in this file you can parametrize by example the following properties (see PAX for more information) :
org.osgi.service.http.port=80
org.ops4j.pax.web.session.timeout=10
You restart Servicemix and now the web site is available at the following address :
http://localhost/sample/index.html
9 comments:
Very nice! Thanks for blogging this useful feature. We should see about getting you write access to the servicemix Wiki so that maybe you could add content like this directly to the Apache online documentation?
Keep up the good work!
Since I already have access to Camel wiki web site, it makes sense that you provide me access to the ServiceMix wiki.
Congratulations for your post!
Did you deployed a war file that uses jsp tag files? Im trying to deploy activeMQ 5.2.0 web console, but im having problems with the tag file inside /web-inf/tags/*.tag . As far i know paxWebExtender loads tld files from the web-inf folder. But in this case, it seems that pax is not handling .tag files (jsp 2 spec)
thanks!
Hi Led,
Many thanks for your greetings.
I haven't tested a deployment of project including tld files. I will test it. I'm almost sure that the MANIFEST file does not include/import the files and in consequence are not loaded by PAX Web JSP bundle
FYI : here is the list of what is exported by PAX Web JSP. As you can see JSP 2.1 is supported :
Export-Package = javax.servlet.jsp.tagext;uses:="javax.servlet.jsp";version="2.1.0",javax.servlet.jsp.el;uses:="javax.servlet.http,javax.servlet,javax.servlet.jsp,javax.e
l";version="2.1.0",javax.servlet.jsp.resources;version="2.1.0",javax.servlet.jsp;uses:="javax.servlet.http,javax.servlet,javax.servlet.jsp.tagext,javax.servlet.jsp.el,jav
ax.el";version="2.1.0",javax.el;version="2.1.0",org.ops4j.pax.web.jsp;uses:="javax.servlet,org.osgi.framework,org.apache.commons.logging";version="0.5.2"
Have you modified the MANIFEST file as explained in the documentation : http://wiki.ops4j.org/display/ops4j/Pax+Web+-+Jsp ?
Regards,
Charles
Nice charles! If pax jsp supports jsp 2.1 spec, i must missing something or the pax-web-jsp bundle :)
the pax web jsp wiki say that the taglib support do two things: 1)look for all tld files in any jar referenced by your Bundle-ClassPath manifest entry
1) look for all tld files in WEB-INF directory or sub-directory of WEB-INF in your bundle jar
maybe the pax web jsp put on the class path just .tld files and misses .tag files... im saying that because my tag files are in a WEB-INF sub folder, where as the wiki says, its a valid place to put .tld files.
Led,
Here is what you have to do in order to solve your problem :
Create a file activemq-web-console.bnd and place it in c:/temp/ with the following content:
WAR-URL=file:///c:/temp/activemq-web-console-5.2.0.war
Bundle-Classpath=., WEB-INF/tags/form, WEB-INF/tags/jms
WebWebapp-Context=activemqweb
and then use on SMX4 the command:
install war-i:file:///c:/temp/activemq-web-console-5.2.0.bnd
Charles,
I did what you said in the previous post and im still having the problem;
Above is a part of osgi headers (MANIFEST) form my war deployed on the SMX 4.
Bundle-ClassPath = WEB-INF/classes,.,WEB-INF/tags/jms/*.tag,WEB-INF/tags/form/tooltip.tag,WEB-INF/tags/form/*.tag,
No even pointing to the specific .tag file , i get the problem solved
The exception is: "org.apache.jasper.JasperException: /topics.jsp(49,75) No tag "tooltip" defined in tag library imported with prefix "form".
Did you tested your bnd customization solution with the activemq-web-console 5.2.0 ???
many thanks for your atention!
PS: im also questioning alin from OPS4J in his blog.
Charles,
I've posted in Alin's blog (http://adreghiciu.blogspot.com/2009/03/ops4j-pax-web-ahead-of-its-time.html) and he told to use pax web snapshot bundles. The released bundles at the moment don't support tag files.
thanks for your atention!
Post a Comment