title: RESTEasy will not map my Spring bean with custom Spring ContextLoader
body: <ul>
  <li>RESTEasy 2.0.1GA</li>
  <li>Java 1.6</li>
  <li>Spring 3.0.3</li>
  </ul>
  
  <p>I have tried everything I can, and cannot make head or tail of what's going on.  I have a Spring MVC application, however I'd like to have some RESTEasy endpoints available <em>outside</em> the Spring MVC app, but in the same container, ultimately being able to wire in the same beans. </p>
  
  <p>As a first step, I'm simply trying to stand-up RESTEasy inside the container, serving requests from a Spring-configured bean.  I have tried the boilerplate from the instructions and have also tried manual setup, to no avail.</p>
  
  <h2>Bean</h2>
  
  <pre><code>@Resource
  @Path("/")
  public class NeighborComparison {
  
      private String foo;
  
      @GET @Path(value="customer") @Produces("text/plain")
      public String getNeighborComparison() {
          return "foo";
      }
  }
  </code></pre>
  
  <h2><code>web.xml</code></h2>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;resteasy.servlet.mapping.prefix&lt;/param-name&gt;
      &lt;param-value&gt;/api&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;!-- NOT configuring SpringContextLoaderListener because I declare my own, so if I do, everything
       blows up, plus  all it actually does is sanity check configuration --&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;com.example.MyCustomContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;Resteasy&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Resteasy&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <h2><code>applicationContext.xml</code></h2>
  
  <pre><code>&lt;bean id="resteasy.providerFactory" class="org.jboss.resteasy.spi.ResteasyProviderFactory"
        factory-method="getInstance"&gt;
  &lt;/bean&gt;
  
  &lt;bean id="resteasy.dispatcher" class="org.jboss.resteasy.core.SynchronousDispatcher"&gt;
      &lt;constructor-arg ref="resteasy.providerFactory"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="resteasy.spring.bean.processor" class="org.jboss.resteasy.plugins.spring.SpringBeanProcessor"&gt;
      &lt;description&gt;
          Add Resources and @Providers to the appropriate places
          in Resteasy's infrastructure
      &lt;/description&gt;
      &lt;constructor-arg ref="resteasy.dispatcher"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="neighborComparison" class="opower.api.customer.neighbor_comparison.NeighborComparison"&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>According to the documentation, all I have to do is “manually register the RESTeasy BeanFactoryPostProcessor by allocating an instance of org.jboss.resteasy.plugins.spring.SpringBeanProcessor”.  I believe this spring configuration does that.</p>
  
  <p>Jetty starts and the app context spins up with no issues.  Application works normally, however when I</p>
  
  <pre><code>&gt; curl -H"Accept: text/plain" localhost:8080/ei/api/customer
  </code></pre>
  
  <p>("ei" is the application context).  The log shows (this and only this):</p>
  
  <pre><code>2011-03-29 16:44:24,153 DEBUG [qtp-575315405-0] [EI] [] [asy.core.SynchronousDispatcher] PathInfo: /customer
  2011-03-29 16:44:24,156 DEBUG [qtp-575315405-0] [EI] [] [asy.core.SynchronousDispatcher] Failed executing GET /customer
  org.jboss.resteasy.spi.NotFoundException: Could not find resource for relative : /customer of full path: http://localhost:8080/ei/api/customer
  </code></pre>
  
  <p>Even if I could convince RESTEasy to show me the mappings, it seems that it's just not discovering my bean.</p>
  
  <p>If I map it explicitly via the <code>resteasy.resources</code> context param, it works, though obviously doesn't have access to auto-wired Spring beans.</p>
  
  <p>Anything else I can try?  I have debug log on the entire RESTEasy codebase and I don't get any messages.  I've also confirmed that Spring is, in fact, creating my bean, so it's just that RESTEasy isn't finding it. </p>