Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NullPointerException for JerseyServletContainerInitializer while deploying web app on Websphere 8.5

I have deployed a JAX-WS Web Service on a WAS 8.5 server. While starting this app gives following error:-

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

Below is the 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>

I am unable to find out what is causing the issue.

like image 786
Sagar Avatar asked Oct 19 '22 06:10

Sagar


1 Answers

It's a Websphere Bug. The IBM implementation of javax.servlet.ServletRegistration.getMappings() returns null. This is not valid. It should return a empty collection. See https://github.com/eclipse-ee4j/jersey/issues/2978 (Old: https://java.net/jira/browse/JERSEY-2706)

There is a Websphere-Fix, but it has to be enabled.

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

You have to set the WebContainer custom property com.ibm.ws.webcontainer.emptyServletMappings to true. See http://www-01.ibm.com/support/docview.wss?rss=180&uid=swg21284395

like image 78
Henrik Voß Avatar answered Jan 03 '23 23:01

Henrik Voß