title: Websphere Application Server Servlet Initialization Error
body: <p>We need to migrate an app that runs on Glassfish to Websphere Application Server (WAS) 8.5.x version. </p>
  
  <p>To see that things are working correctly with a simple setup, I created a sample project with a single rest service. </p>
  
  <p>I did not extend javax.ws.rs.core.Application with my own class, and I only have a class with path annotations. I defined a servlet in web.xml named "javax.ws.rs.core.Application" so that the annotations are scanned and services are expected to be reachable from given servlet url mapping.</p>
  
  <p>When I try to access the service, I get a 404 message. But the real problem is the Apache Wink that comes with standard IBM Websphere libraries.</p>
  
  <p>In the library <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.wink/wink-common/1.1.1-incubating/org/apache/wink/common/internal/lifecycle/DefaultLifecycleManager.java" rel="nofollow">source code</a> (class DefaultLifecycleManager), there is a part like this:</p>
  
  <pre><code>79        if (ApplicationMetadataCollector.isApplication(cls)) {
  80            // by default application subclasses are singletons
  81            return LifecycleManagerUtils.createSingletonObjectFactory(cls);
  82        }
  </code></pre>
  
  <p>The <strong>isApplication(cls)</strong> method should return true, and the singleton factory for it should then be created. However, it returns false. The body of the method is as following:</p>
  
  <pre><code>76    public static boolean More ...isApplication(Class cls) {
  77        return Application.class.isAssignableFrom(cls);
  78    }
  </code></pre>
  
  <p>I put a breakpoint there and checked the values. cls is exactly javax.ws.rs.core.Application, which is the same class in the 77th line.</p>
  
  <p>This leads the servlet to not start correctly and return 404 to every request that maps to it.</p>
  
  <p>I don't know how this method returns false, and I need your help.</p>