title: Error while injection in REST using Jersey/Spring with Tomcat
body: <p>I'm trying to implement REST API using Jersey with Spring on Tomcat but I'm getting error:</p>
  
  <pre><code>INFO: Root resource classes found: class com.abc.restrequest.MyClass
  Feb 15, 2012 6:35:24 AM com.sun.jersey.api.core.ScanningResourceConfig init
  INFO: No provider classes found.
  Feb 15, 2012 6:35:24 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
  INFO: Initiating Jersey application, version 'Jersey: 1.8 06/24/2011 12:17 PM'
  Feb 15, 2012 6:35:24 AM com.sun.jersey.spi.inject.Errors processErrorMessages
  SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
    SEVERE: The class com.abc.service.interface.IMyClassService is an interface and cannot be instantiated.
  Feb 15, 2012 6:35:24 AM org.apache.catalina.core.ApplicationContext log
  SEVERE: StandardWrapper.Throwable
  com.sun.jersey.spi.inject.Errors$ErrorMessagesException
  </code></pre>
  
  <h1>web.xml:</h1>
  
  <pre><code>&lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;context-param&gt;
          &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/classes/log4j.properties&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/classes/startup.xml,classpath*:startup.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
      &lt;init-param&gt;
           &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
           &lt;param-value&gt;com.abc.restrequest&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 REST Service&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/service/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;  
  </code></pre>
  
  <h1>MyResourse.java</h1>
  
  <pre><code>@Inject
  private IMyClassService serviceImpl;
  
  @Override
  public void setServiceImpl(IMyClassService impl) {
      serviceImpl = impl;     
  }   
  
  @Path("/mycall")
  @POST
  @Consumes ({MediaType.APPLICATION_JSON})
  @Produces ({MediaType.APPLICATION_JSON})
  public Response hellouser() throws ParseException {
          try {
          serviceImpl.callme();
          return Response.noContent().build();
      } catch (Exception e) {
          return Response.status(500).entity(e.getLocalizedMessage()).build();
      }
  }
  </code></pre>
  
  <h1>startup.xml</h1>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core"
      xmlns:jaxws="http://cxf.apache.org/jaxws"  xmlns:context="http://www.springframework.org/schema/context"
      xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
          http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
          http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
          http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
      "&gt;
  
      &lt;context:component-scan base-package="com.abc.restrequest" /&gt;
      &lt;context:annotation-config /&gt;
  
      &lt;bean id="myrestservice" scope="prototype" class="com.abc.service.implementation.MyClassServiceImpl"&gt;
      &lt;/bean&gt;
  &lt;/beans&gt; 
  </code></pre>
  
  <p>MyClassServiceImpl implements IMyClassService</p>
  
  <p>Can any one tell me why I'm getting the error?
  The class com.abc.service.interface.IMyClassService is an interface and cannot be instantiated.</p>
  
  <p>I'll really appreciate if you can help me out!!</p>
  
  <p>Thanks!</p>