Sling Pax Web Extender sample webapp ------------------------------------ This (very simple) prototype webapp can be loaded as an OSGi bundle in Sling. The goal is to demonstrate that "almost" normal webapps can be loaded as OSGi bundles and run alongside Sling-managed servlets. The only "special" parts of this webapp are: 1) maven-bundle-plugin and maven-war-plugin configurations in the pom.xml, to make the generated war file an OSGi bundle. 2) The Activator class, which demonstrates how to access the OSGi BundleContext, which in turn gives access to OSGi services. The rest is standard JEE stuff. How to test this ---------------- Build this war file using "mvn clean install". Start the Sling launchpad/app server, http://localhost:8080/index.html should display the "Welcome to the Sling Launchpad" page. Update the "OPS4J Pax Web - Service" bundle to 0.5.2, available from http://repository.ops4j.org/maven2/org/ops4j/pax/web/pax-web-service/ and verify that the above page still works. Install and start the Pax Web Extender bundle (pax-web-ex-war, tested with 0.0.5) found at http://repository.ops4j.org/maven2/org/ops4j/pax/web-extender/pax-web-ex-war/ Seems like that bundle must be started *after* the Sling engine bundle, as both are trying to register resources on /, and the last one fails. To fix this, I assume we need a simple change in the Pax Web Extender, to make that mount path configurable. Install and start this module's war file, as if it was a "normal" OSGi bundle. All URLs under http://localhost:8080/org.apache.sling.samples.pax-webapp/ must now return the output of this webapp's TestServlet, that is something like This is org.apache.sling.samples.pax.webapp.TestServlet Current date is Tue Apr 07 14:41:06 CEST 2009 Filter: null Activator info: Symbolic name=org.apache.sling.samples.pax-webapp, location=inputstream:org.apache.sling.samples.pax-webapp.war The "Activator info" demonstrates that the OSGi BundleContext can be accessed from the webapp, allowing it to access Sling services. Also, all URLs under http://localhost:8080/org.apache.sling.samples.pax-webapp/filter/ must say Filter: org.apache.sling.samples.pax.webapp.TestFilter instead of "Filter: null" as above, this demonstrates that the TestFilter class is correctly activated. Where next? ----------- The next step would to verify that this setup correctly handles the web.xml and JEE featuers that your specific apps need. A list of web.xml elements supported by Pax Web can be found at http://wiki.ops4j.org/display/ops4j/Pax+Web+Extender+-+War+-+Supported+Elements See Also --------- http://wiki.ops4j.org/display/ops4j/Pax+Web+Extender