0

I am deploying web application having jersey 2.25 on WebSphere 8.5.5.9. We are registering resources via below class.

public class ApplicationResourceConfig extends ResourceConfig {

/**
 * 
 */
public ApplicationResourceConfig() {
    packages(verifyAndLoadResources());
}

/**
 * @return
 */
private String[] getAllResources() {
    List<String> resources = new ArrayList<>();
    resources.add("com.ofs.fsapps.commonapps.appPreferences.resource.AppPreferencesResource");  

    resources.add("com.ofs.fsapps.commonapps.summary.rest.Summary");
    return resources.toArray(new String[0]);
}

/**
 * @return
 */
private String[] verifyAndLoadResources() {
    List<String> packageResourceList = new ArrayList<>();
    for (String resource : getAllResources()) {
        try {
            Class<?> result = Class.forName(resource);
            if (result != null) {
                register(StringUtils.substringAfterLast(resource, ".") + ".class");
                packageResourceList.add(StringUtils.substringBeforeLast(resource, "."));
            }
        } catch (ClassNotFoundException e) {
            System.out.println("Package/Class not Found : "+resource);
        }catch(Exception e) {
            System.out.println("Exception in loading Package/Class : "+resource);
        }
    }
    return packageResourceList.toArray(new String[0]);
}

}

With above approach, none of the rest calls are working and responding as 404. If we make entry of packages/classes in web.xml then everything is working properly.

    <servlet>
    <servlet-name>CommonRESTServlet</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>

    <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>com.ofs.fsapps.commonapps.summary.rest.Summary, com.ofs.fsapps.commonapps.appPreferences.resource.AppPreferencesResource</param-value>
    </init-param>
</servlet>

Please note that shared library has been created and the same is linked with EAR as well.

Below are exceptions in SystemErr.log.

java.lang.NullPointerException at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.existsServletForUrlPattern(WSServletContextListener.java:186) at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.registerWSServlet(WSServletContextListener.java:168) at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.parseAdaptersAndCreateDelegate(WSServletContextListener.java:132) at com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer.onStartup(WSServletContainerInitializer.java:65) at com.ibm.ws.webcontainer.webapp.WebAppImpl.initializeServletContainerInitializers(WebAppImpl.java:619) 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:170) at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:904) at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:789) at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:427) at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:719)

  • 1
    Possible duplicate of [JAX-RS Jersey 2.10 support in Websphere 8](https://stackoverflow.com/questions/24684958/jax-rs-jersey-2-10-support-in-websphere-8) – Gas Nov 24 '18 at 18:20
  • @Gas i have tried all the suggestions mentioned in post shared by you. Still not working. – Abhishek verma Nov 26 '18 at 04:24
  • 1
    Did you set this property `com.ibm.websphere.jaxrs.server.DisableIBMJAXRSEngine=true` in JVM or Meta-INF? – Gas Nov 26 '18 at 08:17

0 Answers0