java.lang.NullPointerException 在 Websphere 8.5 上部署 Web 应用程序时用于 JerseyServletContainerInitializer
java.lang.NullPointerException for JerseyServletContainerInitializer while deploying web app on Websphere 8.5
我已经在 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">
<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 错误。 javax.servlet.ServletRegistration.getMappings()
returns null
的 IBM 实现。这是无效的。它应该 return 一个空集合。参见 https://github.com/eclipse-ee4j/jersey/issues/2978 (Old: 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
我已经在 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">
<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 错误。 javax.servlet.ServletRegistration.getMappings()
returns null
的 IBM 实现。这是无效的。它应该 return 一个空集合。参见 https://github.com/eclipse-ee4j/jersey/issues/2978 (Old: 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