5
votes

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.

1
@Jens The NullPointerException is occurring in a library that the user does not control, so that suggested duplicate is irrelevant. - Brett Kail
I have already tried out the solution provided in topic [link] stackoverflow.com/questions/24684958/… but it did not work. Moreover, as Brett pointed out that NullPointerException is occurring at Jersey library level in spite of having proper configuration in web.xml and user defined file level. I tried it out in Diffrenet versions of WebSphere(8.0,8.5 and 8.5.5). It worked in Websphere 7 but I think it broke from 8.0. Possible workaround is welcome. Please provide any such. - Sagar

1 Answers

3
votes

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