Search code examples
jsfosgipax-web

Apache Karaf Deploying .War File


My purpose is to run a JSF application on OSGI Framework. So, I am trying to deploy a WAR file to a servlet container for OSGi web applications, called PAX-WEB. I have a proper working JSF implementation working on WildFly 8.0 application server. I succesfully created OSGi-ified WAR file from this application. When I try to deploy it into PAX-WEB using Maven the following error occurs:

missing requirement: javax.servlet.annotation

I have these JARs in /lib folder of my application: jsf-api-2.1.7, jsf-impl-2.1.7, jsp-api-2.1, jstl-1.2. When I add javax.servlet-api-3.0.1.jar to my WAR file and re-deploy it, this time the following error occurs:

javax.faces.webapp.FacesServlet cannot be cast to javax.servlet.Servlet

With this error, I can run my JSF page, but it is not displaying JSF tags.


Solution

  • You're mixing two issues here. One, your framework setup is missing the servlet classes. So in that case I propose to use the pax-web-jetty-bundle. It's an uber bundle and also contains and exports the servlet classes. In that case make sure you don't have the servlet jars in your framework setup available. Btw. taking a look at the samples and Integration tests of Pax Web itself helps already to understand which libraries are needed.

    The second issue you are facing is an issue of adding the servlet classes to the war, this is per OSGi and servlet spec forbidden to do.

    So without any further knowledge of your scenario you might be better of with using the Apache Karaf server (it uses Pax Web), cause there all infrastructure bundles are already included and known to work together.

    One more thing, you get more and better feedback at the ops4j mailinglist.