Apache Felix with Pax Web War Extender error starting bundle

1.2k views Asked by At

I'm developing with Osgi and Apache Felix and I have this problem. When I install and start the war of my Jersey project on my Apache Felix I get this:

org.ops4j.pax.web.pax-web-extender-war[org.ops4j.pax.web.extender.war.internal.Activator] : Starting destruction process for bundle platform-component-web-rest-service-authentication
org.ops4j.pax.web.pax-web-extender-war[org.ops4j.pax.web.extender.war.internal.Activator] : Not an extended bundle or destruction of extension already finished for platform-component-web-rest-service-authentication.
Started activator
org.ops4j.pax.web.pax-web-extender-war[org.ops4j.pax.web.extender.war.internal.WebObserver] : Ignore bundle platform-component-web-rest-service-authentication [193] which is not compatible with this extender

I have these bundles installed:

    0|Active     |    0|System Bundle (4.4.1)
    1|Active     |    1|Apache Felix Bundle Repository (2.0.2)
    2|Active     |    1|Apache Felix Gogo Command (0.14.0)
    4|Active     |    1|Apache Felix Gogo Shell (0.10.0)
   10|Active     |    1|Apache Felix Configuration Admin Service (1.2.8)
   11|Active     |    1|Apache Felix EventAdmin (1.2.10)
   35|Active     |    1|Apache Felix Gogo Runtime (0.12.1)
   90|Active     |    1|Apache Felix Log Service (1.0.0)
   91|Active     |    1|OSGi R4 Compendium Bundle (4.0.0)
   92|Active     |    1|Apache Felix Declarative Services (1.6.0)
   93|Active     |    1|Apache Felix iPOJO (1.8.0)
   94|Active     |    1|Apache Felix Web Management Console (3.1.2)
   95|Active     |    1|Apache Felix iPOJO WebConsole Plugins (1.6.0)
   96|Active     |    1|Apache Felix Shell Service (1.4.2)
  119|Active     |    1|Servlet 2.1 API (1.0.0)
  144|Active     |    1|OSGi JAX-RS Connector (4.1.0.201407081443)
  147|Active     |    1|jersey-all (2.10.1)
  157|Active     |    1|OPS4J Pax Web - Jetty Bundle (4.0.0)
  158|Active     |    1|OPS4J Pax Web - Runtime (4.0.0)
  163|Active     |    1|http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7-sources.jar (0.0.0)
  165|Active     |    1|Java Servlet API (3.0.1)
  167|Active     |    1|OPS4J Pax Logging - API (1.8.1)
  170|Active     |    1|Apache Felix Dependency Manager (3.2.0)
  171|Active     |    1|OPS4J Pax Web - Extender - WAR (4.0.0)
  174|Active     |    1|Apache Felix Dependency Manager Runtime (3.2.0)
  177|Active     |    1|ASM (5.0.3)
  178|Active     |    1|ASM commons classes (5.0.3)
  179|Active     |    1|ASM Tree class visitor (5.0.3)
  182|Active     |    1|Apache XBean OSGI Bundle Utilities (3.18.0)
  183|Active     |    1|Apache XBean :: Classpath Resource Finder (3.18.0)
  193|Active     |    1|Auth Test (2.0.0.SNAPSHOT)

My activator is the standard:

public class WebAppContextListener implements BundleActivator, ServletContextListener {

static EventAdmin ea;

BundleContext bc;
ServiceReference eaRef;

synchronized static EventAdmin getEa() {
    return ea;
}

synchronized static void setEa(EventAdmin ea) {
    WebAppContextListener.ea = ea;
}

@Override
public void contextInitialized(final ServletContextEvent sce) {
    if (getEa() != null) {
        final String contextPath = sce.getServletContext().getContextPath();
        getEa().sendEvent(new Event("jersey/test/DEPLOYED",new HashMap<String, String>(){{
            put("context-path", contextPath);}}));
    }
}

@Override
public void contextDestroyed(final ServletContextEvent sce) {
    if (getEa() != null) {
        getEa().sendEvent(new Event("jersey/test/UNDEPLOYED",new HashMap<String, String>(){{put("context-path", sce.getServletContext().getContextPath());}}));
    }
}

@Override
public void start(BundleContext context) throws Exception {
    System.out.println("Started Activator");
    bc = context;
    eaRef = bc.getServiceReference(EventAdmin.class.getName());
    if (eaRef != null) {
        setEa((EventAdmin)bc.getService(eaRef));
    }
}

@Override
public void stop(BundleContext context) throws Exception {
    if (eaRef != null) {
        setEa(null);
        bc.ungetService(eaRef);
    }
}

}

My MANIFEST.MF looks like:

Manifest-Version: 1.0
Export-Package: com.mycompany.platform.component.web.rest.service.authent
 ication.services;uses:="org.osgi.service.event,org.osgi.framework";ve
 rsion="2.0.0.SNAPSHOT"
Embed-Directory: WEB-INF/lib
Implementation-Title: Auth Test
Bundle-ClassPath: .,WEB-INF/classes,WEB-INF/lib/hk2-api-2.3.0-b10.jar,
 WEB-INF/lib/oro-2.0.8.jar,WEB-INF/lib/jcs-1.3.jar,WEB-INF/lib/concurr
 ent-1.0.jar,WEB-INF/lib/log4j-1.2.12.jar,WEB-INF/lib/mimepull-1.8.jar
 ,WEB-INF/lib/commons-dbcp-1.4.jar,WEB-INF/lib/jersey-client-2.12.jar,
 WEB-INF/lib/osgi-resource-locator-1.0.1.jar,WEB-INF/lib/jackson-jaxrs
 -json-provider-2.4.1.jar,WEB-INF/lib/jazzy-0.5.1.jar,WEB-INF/lib/comm
 ons-beanutils-1.7.0.jar,WEB-INF/lib/bonecp-0.8.0.RELEASE.jar,WEB-INF/
 lib/json4s-core_2.11-3.2.10.jar,WEB-INF/lib/javax.servlet-api-3.0.1.j
 ar,WEB-INF/lib/snakeyaml-1.13.jar,WEB-INF/lib/swagger-annotations-1.3
 .8.jar,WEB-INF/lib/jsr305-2.0.1.jar,WEB-INF/lib/scala-library-2.11.1.
 jar,WEB-INF/lib/joda-convert-1.6.jar,WEB-INF/lib/commons-jxpath-1.2.j
 ar,WEB-INF/lib/scala-parser-combinators_2.11-1.0.1.jar,WEB-INF/lib/ja
 spell-0.3.jar,WEB-INF/lib/ant-optional-1.5.1.jar,WEB-INF/lib/platform
 -component-manager-user-2.0.0-SNAPSHOT.jar,WEB-INF/lib/platform-compo
 nent-manager-commons-2.0.0-SNAPSHOT.jar,WEB-INF/lib/metrics-core-3.1.
 0.jar,WEB-INF/lib/platform-component-manager-cache-2.0.0-SNAPSHOT.jar
 ,WEB-INF/lib/junit-4.11.jar,WEB-INF/lib/slf4j-api-1.7.5.jar,WEB-INF/l
 ib/commons-pool-1.3.jar,WEB-INF/lib/swagger-jersey2-jaxrs_2.11-1.3.8.
 jar,WEB-INF/lib/commons-beanutils-core-1.7.0.jar,WEB-INF/lib/json4s-e
 xt_2.11-3.2.10.jar,WEB-INF/lib/berkeleydb-1.5.1.jar,WEB-INF/lib/commo
 ns-lang-2.4.jar,WEB-INF/lib/validation-api-1.1.0.Final.jar,WEB-INF/li
 b/javassist-3.16.1-GA.jar,WEB-INF/lib/lib-utils-0.2.0.jar,WEB-INF/lib
 /xmlrpc-2.0.jar,WEB-INF/lib/paranamer-2.6.jar,WEB-INF/lib/jackson-cor
 e-2.4.1.jar,WEB-INF/lib/hk2-locator-2.3.0-b10.jar,WEB-INF/lib/commons
 -logging-1.1.jar,WEB-INF/lib/ojdbc6-11.2.0.4.jar,WEB-INF/lib/commons-
 io-2.4.jar,WEB-INF/lib/dom4j-1.6.1.jar,WEB-INF/lib/jackson-databind-2
 .4.1.1.jar,WEB-INF/lib/platform-component-service-authentication-comm
 ons-2.0.0-SNAPSHOT.jar,WEB-INF/lib/jackson-annotations-2.4.1.jar,WEB-
 INF/lib/platform-component-service-authentication-2.0.0-SNAPSHOT.jar,
 WEB-INF/lib/mysql-connector-java-5.1.32.jar,WEB-INF/lib/lib-utils-web
 -0.3.0.jar,WEB-INF/lib/platform-component-manager-tenant-2.0.0-SNAPSH
 OT.jar,WEB-INF/lib/scalap-2.11.0.jar,WEB-INF/lib/platform-component-w
 eb-rest-commons-2.0.0-SNAPSHOT.jar,WEB-INF/lib/postgresql-9.1-901.jdb
 c4.jar,WEB-INF/lib/jersey-guava-2.12.jar,WEB-INF/lib/jackson-jaxrs-ba
 se-2.4.1.jar,WEB-INF/lib/lib-language-en-0.1.1.jar,WEB-INF/lib/javax.
 annotation-api-1.2.jar,WEB-INF/lib/platform-component-service-commons
 -2.0.0-SNAPSHOT.jar,WEB-INF/lib/joda-time-2.3.jar,WEB-INF/lib/json4s-
 native_2.11-3.2.10.jar,WEB-INF/lib/sqljdbc4-4.0.jar,WEB-INF/lib/guice
 -3.0.jar,WEB-INF/lib/scala-xml_2.11-1.0.1.jar,WEB-INF/lib/jersey-serv
 er-2.12.jar,WEB-INF/lib/avalon-framework-4.1.3.jar,WEB-INF/lib/lib-la
 nguage-es-0.1.1.jar,WEB-INF/lib/jdom2-2.0.5.jar,WEB-INF/lib/xml-apis-
 1.0.b2.jar,WEB-INF/lib/commons-digester-1.8.jar,WEB-INF/lib/pdb-2.0.2
 .jar,WEB-INF/lib/jersey-container-servlet-2.12.jar,WEB-INF/lib/reflec
 tions-0.9.9-RC1.jar,WEB-INF/lib/lib-language-pt-0.1.1.jar,WEB-INF/lib
 /javax.inject-2.2.0-b10.jar,WEB-INF/lib/lib-language-commons-0.1.1.ja
 r,WEB-INF/lib/platform-commons-2.0.0-SNAPSHOT.jar,WEB-INF/lib/aopalli
 ance-1.0.jar,WEB-INF/lib/commons-codec-1.8.jar,WEB-INF/lib/logback-cl
 assic-1.0.13.jar,WEB-INF/lib/lucene-analyzers-common-4.5.1.jar,WEB-IN
 F/lib/commons-configuration-1.4.jar,WEB-INF/lib/scala-compiler-2.11.0
 .jar,WEB-INF/lib/jersey-container-servlet-core-2.1.jar,WEB-INF/lib/pl
 atform-component-manager-license-2.0.0-SNAPSHOT.jar,WEB-INF/lib/tomca
 t-util-3.2.1.jar,WEB-INF/lib/jackson-module-jsonSchema-2.4.1.jar,WEB-
 INF/lib/velocity-1.5.jar,WEB-INF/lib/scala-reflect-2.11.1.jar,WEB-INF
 /lib/hamcrest-core-1.3.jar,WEB-INF/lib/jersey-media-multipart-2.1.jar
 ,WEB-INF/lib/commons-logging-api-1.0.4.jar,WEB-INF/lib/logkit-1.0.1.j
 ar,WEB-INF/lib/jersey-common-2.12.jar,WEB-INF/lib/platform-component-
 manager-language-2.0.0-SNAPSHOT.jar,WEB-INF/lib/logback-core-1.0.13.j
 ar,WEB-INF/lib/platform-component-manager-database-2.0.0-SNAPSHOT.jar
 ,WEB-INF/lib/json4s-jackson_2.11-3.2.10.jar,WEB-INF/lib/javax.inject-
 1.jar,WEB-INF/lib/json4s-ast_2.11-3.2.10.jar,WEB-INF/lib/hk2-utils-2.
 3.0-b10.jar,WEB-INF/lib/guava-15.0.jar,WEB-INF/lib/commons-lang3-3.1.
 jar,WEB-INF/lib/gson-2.2.4.jar,WEB-INF/lib/jackson-module-jaxb-annota
 tions-2.4.1.jar,WEB-INF/lib/xerces-1.2.3.jar,WEB-INF/lib/liquibase-co
 re-3.2.2.jar,WEB-INF/lib/aopalliance-repackaged-2.3.0-b10.jar,WEB-INF
 /lib/swagger-core_2.11-1.3.8.jar,WEB-INF/lib/jackson-module-scala_2.1
 1-2.4.1.jar,WEB-INF/lib/swagger-jaxrs_2.11-1.3.8.jar,WEB-INF/lib/java
 x.ws.rs-api-2.0.1.jar
Built-By: jmartins
Tool: Bnd-0.0.357
Web-ContextPath: authentication
Implementation-Vendor: mycompany, Lda
Implementation-Vendor-Id: com.mycompany.platform.component.web.rest.servi
 ce
Embed-Transitive: true
Bundle-Activator: com.mycompany.platform.component.web.rest.service.authe
 ntication.services.WebAppContextListener
Specification-Title: Auth Test
Bundle-SymbolicName: platform-component-web-rest-service-authenticatio
 n
Webapp-Context: authentication
Implementation-Version: 2.0.0-SNAPSHOT
Specification-Vendor: mycompany, Lda
Bundle-Name: Auth Test
Created-By: 1.7.0_72 (Oracle Corporation)
Bundle-Vendor: mycompany, Lda
Build-Jdk: 1.7.0_72
Bundle-Version: 2.0.0.SNAPSHOT
Bnd-LastModified: 1415982968397
Bundle-ManifestVersion: 2
Embed-Dependency: *;scope=compile|runtime
Bundle-DocURL: http://mycompany.com
Import-Package: com.mycompany.platform.component.web.rest.service.authent
 ication.services;version="2.0",org.osgi.framework;version="1.5",org.o
 sgi.service.event;version="1.2"
Embed-StripGroup: true
Specification-Version: 2.0.0-SNAPSHOT
Archiver-Version: Plexus Archiver

When I do a request to http://localhost:8080/authentication/rest/2.0.0/authentication/auth for example I get 404 and it seems that the war is not even deployed. Any ideas on what could this be?

2

There are 2 answers

0
Achim Nierbeck On BEST ANSWER

Don't embed the servlet API inside your application.

WEB-INF/lib/javax.servlet-api-3.0.1.j

ar This is not allowed to be in WARs (not even int std. Application containers) This might already be your root cause.

1
Harald Wellmann On

Pax Web logs the "not compatible with this extender" error when your bundle cannot load javax.servlet.Servlet. Try adding a package import.