title: Bootstrapping Jersey with a filter causes Swagger to fail
body: <p>In my application's <code>web.xml</code> I originally had Jersey configured as follows:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;jersey-servlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.spring.container.servlet.SpringServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
          &lt;!-- swagger for REST API support
               codehaus for exception mappings so, for ex, POSTing malformed JSON  yields 400 bad request not 500 --&gt;
          &lt;param-value&gt;com.jonarcher.rest;com.wordnik.swagger.jaxrs;org.codehaus.jackson.jaxrs&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;!-- Passed thru to Swagger --&gt;
          &lt;param-name&gt;api.version&lt;/param-name&gt;
          &lt;param-value&gt;2.0&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;jersey-servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>This seems to work just fine, and I can use the swagger-ui to browse documentation of my annotated endpoints.</p>
  
  <p>However, I want to "embed" the swagger UI in my application so that the means of browsing the documentation goes along with it. I ran into problems serving the static content for swagger-ui considering the <code>&lt;url-pattern&gt;</code> for my Jersey servlet. Obviously I can change that to, for example, <code>/api/*</code> but that is actually not desirable in my situation.</p>
  
  <p>I read <a href="http://www.flamingpenguin.co.uk/blog/2010/09/02/serving-static-content-and-jersey/" rel="nofollow">here</a> that Jersey can be configured to run as a filter rather than a servlet, and then that you can specify a parameter for URLs to exclude from Jersey processing thus: </p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;jerseyFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;com.sun.jersey.spi.spring.container.servlet.SpringServlet&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.config.property.WebPageContentRegex&lt;/param-name&gt;
          &lt;param-value&gt;.*\.html&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;jerseyFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>That works fine too by itself. But when I bring swagger into the mix things start to go awry. Specifically, introducing the <code>com.sun.jersey.config.property.packages</code> param to the filter based configuration as I had it in the servlet configuration like so:</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;jerseyFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;com.sun.jersey.spi.spring.container.servlet.SpringServlet&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.config.property.WebPageContentRegex&lt;/param-name&gt;
          &lt;param-value&gt;.*\.html&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
          &lt;param-value&gt;com.jonarcher.rest;com.wordnik.swagger.jaxrs;org.codehaus.jackson.jaxrs&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;jerseyFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>Causes the filter to fail to start, and the following error messages:</p>
  
  <pre><code>  SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
    SEVERE: Missing dependency for method public javax.ws.rs.core.Response com.wordnik.swagger.jaxrs.ApiListingResourceJSON.getAllApis(javax.servlet.ServletConfig,com.sun.jersey.api.core.ResourceConfig,javax.ws.rs.core.HttpHeaders,javax.ws.rs.core.UriInfo) at parameter at index 0
    SEVERE: Method, public javax.ws.rs.core.Response com.wordnik.swagger.jaxrs.ApiListingResourceJSON.getAllApis(javax.servlet.ServletConfig,com.sun.jersey.api.core.ResourceConfig,javax.ws.rs.core.HttpHeaders,javax.ws.rs.core.UriInfo), annotated with GET of resource, class com.wordnik.swagger.jaxrs.ApiListingResourceJSON, is not recognized as valid resource method.
    SEVERE: Missing dependency for method public javax.ws.rs.core.Response com.wordnik.swagger.jaxrs.ApiListingResourceXML.getAllApis(javax.servlet.ServletConfig,com.sun.jersey.api.core.ResourceConfig,javax.ws.rs.core.HttpHeaders,javax.ws.rs.core.UriInfo) at parameter at index 0
    SEVERE: Method, public javax.ws.rs.core.Response com.wordnik.swagger.jaxrs.ApiListingResourceXML.getAllApis(javax.servlet.ServletConfig,com.sun.jersey.api.core.ResourceConfig,javax.ws.rs.core.HttpHeaders,javax.ws.rs.core.UriInfo), annotated with GET of resource, class com.wordnik.swagger.jaxrs.ApiListingResourceXML, is not recognized as valid resource method.
  Oct 18, 2012 11:27:30 AM com.sun.jersey.spi.spring.container.servlet.SpringServlet initiate
  SEVERE: Exception occurred when intialization
  com.sun.jersey.spi.inject.Errors$ErrorMessagesException
      at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
      at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
      at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:765)
      at com.sun.jersey.spi.spring.container.servlet.SpringServlet.initiate(SpringServlet.java:117)
      at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319)
      at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:609)
      at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
      at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
      at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:727)
      at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
      at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
      at org.apache.catalina.core.ApplicationFilterConfig.&lt;init&gt;(ApplicationFilterConfig.java:115)
      at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4071)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4725)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
      at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
      at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
      at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
      at org.apache.catalina.core.StandardService.start(StandardService.java:525)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
  </code></pre>
  
  <p>I got stuck at this point. Anyone have any suggestions/pointers?</p>