在Websphere 8.5上部署Web应用程序时,JerseyServletContainerInitializer的java.lang.NullPointerException

我在WAS 8.5服务器上部署了JAX-WS Web服务.启动此应用程序时出现以下错误: –

com.ibm.ws.exception.RuntimeWarning: com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: Failed to load webapp: null
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:432)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1175)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)


Caused by: java.lang.NullPointerException
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.mappingExists(JerseyServletContainerInitializer.java:331)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.addServletWithApplication(JerseyServletContainerInitializer.java:272)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartupImpl(JerseyServletContainerInitializer.java:176)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartup(JerseyServletContainerInitializer.java:143)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initializeServletContainerInitializers(WebAppImpl.java:613)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:409)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169)
... 101 more

下面是web.xml: –

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd\”\u0026gt;

<display-name>My Event</display-name>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/applicationContext.xml
        WEB-INF/classes/configs/*.xml
    </param-value>
</context-param>
<!--<context-param>
    <param-name>contextClass</param-name>
    <param-value>com.javaetmoi.core.spring.JBoss5XmlWebApplicationContext</param-value>
</context-param>--> 
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
<servlet>
    <servlet-name>jerseyServlet</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer
    </servlet-class>
    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>com.myapp.event.ws.JerseyConfig</param-value>
    </init-param>

  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>jerseyServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

我无法找出导致问题的原因.

最佳答案 这是一个Websphere Bug. javax.servlet.ServletRegistration.getMappings()的IBM实现返回null.这是无效的.它应该返回一个空集合.见
https://java.net/jira/browse/JERSEY-2706

有一个Websphere-Fix,但必须启用它.

A new WebContainer custom property needs to be set to enable the behavior provided by this APAR:

http://www-01.ibm.com/support/docview.wss?uid=swg1PI23529

您必须将WebContainer自定义属性com.ibm.ws.webcontainer.emptyServletMappings设置为true.见http://www-01.ibm.com/support/docview.wss?rss=180&uid=swg21284395

点赞