Java Apache Felix with Pax Web War Extender启动捆绑包时出错

Java Apache Felix with Pax Web War Extender启动捆绑包时出错,java,jersey,osgi,apache-felix,pax-web,Java,Jersey,Osgi,Apache Felix,Pax Web,我正在使用Osgi和ApacheFelix进行开发,我遇到了这个问题。 当我在ApacheFelix上安装并启动“泽西之战”项目时,我得到以下信息: 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-authent

我正在使用Osgi和ApacheFelix进行开发,我遇到了这个问题。 当我在ApacheFelix上安装并启动“泽西之战”项目时,我得到以下信息:

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
我已经安装了这些捆绑包:

    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)
我的激活器是标准的:

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);
    }
}
当我请求
http://localhost:8080/authentication/rest/2.0.0/authentication/auth
例如,我得到了404,而战争似乎还没有展开。
有什么想法吗?

当您的包无法加载
javax.servlet.servlet
时,Pax Web会记录“与此扩展器不兼容”错误。尝试添加包导入。

不要在应用程序中嵌入servlet API

WEB-INF/lib/javax.servlet-api-3.0.1.j
ar 这在战争中是不允许的(即使是int标准应用程序容器也不允许)
这可能已经是你的根本原因了

我必须导入javax.servlet,激活器启动。现在我无法在jetty上发布我的webapp,或者它没有完成发布:org.ops4j.pax.web.pax web extender war[org.ops4j.pax.web.extender.war.internal.Activator]:异步调度捆绑平台组件web rest服务身份验证的扩展启动org.ops4j.pax.web.pax-web-extender-war[org.ops4j.pax.web.extender.war.internal.WebAppPublisher]:发布web应用程序[WebApp{displayName=Authentication Manager,contextName=Authentication,m_httpContext=null}],日志停止在那里。我发出一个请求,得到404。只要一条注释,您就应该执行更多导入,而不是将所有依赖项嵌入war中。
WEB-INF/lib/javax.servlet-api-3.0.1.j