title: Jersey - Spring 3 autowiring (NoClassDefFoundError: EnvironmentAware)
body: <p>I'm trying to implement a proyect using Spring 3.1.2.RELEASE with Jersey 1.13 on a Tomcat 7 server.
  My problem is that when I tried to autowire a service into the rest implementation, the service bean turned <code>null</code> everytime.</p>
  
  <p>I found a suggestion, to set this in the <code>web.xml</code></p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;jersey-serlvet&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;param-value&gt;com.mac.rest&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;load-on-startup&gt;2&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Now, I get this error</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/springframework/context/EnvironmentAware
  </code></pre>
  
  <p>I don't know what's wrong, maybe you can help me figure this out</p>
  
  <p>this is my <code>web.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
           id="WebApp_ID" version="2.5"&gt;
      &lt;display-name&gt;localito&lt;/display-name&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;jersey-serlvet&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;param-value&gt;com.mac.rest&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;load-on-startup&gt;2&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>and this my <code>pom.xml</code></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;project&gt;
          &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
          &lt;groupId&gt;localito&lt;/groupId&gt;
          &lt;artifactId&gt;localito&lt;/artifactId&gt;
          &lt;packaging&gt;war&lt;/packaging&gt;
          &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
          &lt;description&gt;&lt;/description&gt;
          &lt;build&gt;
              &lt;finalName&gt;${project.build.finalName}&lt;/finalName&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-install-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.3.1&lt;/version&gt;
                      &lt;executions&gt;
                          &lt;execution&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;install-file&lt;/goal&gt;
                              &lt;/goals&gt;
                              &lt;phase&gt;install&lt;/phase&gt;
                              &lt;configuration&gt;
                                  &lt;file&gt;${project.build.finalName}.${project.packaging}&lt;/file&gt;
                                  &lt;generatePom&gt;false&lt;/generatePom&gt;
                                  &lt;pomFile&gt;pom.xml&lt;/pomFile&gt;
                                  &lt;version&gt;${my.version}&lt;/version&gt;
                              &lt;/configuration&gt;
                          &lt;/execution&gt;
                      &lt;/executions&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/build&gt;
          &lt;repositories&gt;
              &lt;repository&gt;
                  &lt;id&gt;java.net&lt;/id&gt;
                  &lt;url&gt;http://download.java.net/maven/2/&lt;/url&gt;
              &lt;/repository&gt;
              &lt;repository&gt;
                  &lt;url&gt;http://download.eclipse.org/rt/eclipselink/maven.repo/&lt;/url&gt;
                  &lt;id&gt;eclipselink&lt;/id&gt;
                  &lt;layout&gt;default&lt;/layout&gt;
                  &lt;name&gt;Repository for library Library[eclipselink]&lt;/name&gt;
              &lt;/repository&gt;
              &lt;repository&gt;
                  &lt;id&gt;maven2-repository.java.net&lt;/id&gt;
                  &lt;name&gt;Java.net Repository for Maven&lt;/name&gt;
                  &lt;url&gt;http://download.java.net/maven/2/&lt;/url&gt;
                  &lt;layout&gt;default&lt;/layout&gt;
              &lt;/repository&gt;
          &lt;/repositories&gt;
  
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
                  &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
                  &lt;version&gt;2.5&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
                  &lt;version&gt;${org.springframework.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
                  &lt;version&gt;${org.springframework.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
                  &lt;version&gt;${org.springframework.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
                  &lt;version&gt;${org.springframework.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
                  &lt;version&gt;${org.springframework.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
                  &lt;version&gt;${org.springframework.version}&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                  &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
                  &lt;version&gt;3.3.2.ga&lt;/version&gt;
                  &lt;exclusions&gt;
                      &lt;exclusion&gt;
                          &lt;groupId&gt;cglib&lt;/groupId&gt;
                          &lt;artifactId&gt;cglib&lt;/artifactId&gt;
                      &lt;/exclusion&gt;
                  &lt;/exclusions&gt;
              &lt;/dependency&gt;
              &lt;!-- dependency&gt;
                &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
                &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
                &lt;version&gt;1.4.2&lt;/version&gt;
              &lt;/dependency --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;taglibs&lt;/groupId&gt;
                  &lt;artifactId&gt;standard&lt;/artifactId&gt;
                  &lt;version&gt;1.1.2&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
                  &lt;artifactId&gt;jstl&lt;/artifactId&gt;
                  &lt;version&gt;1.1.2&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;mysql&lt;/groupId&gt;
                  &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
                  &lt;version&gt;5.1.10&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
                  &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
                  &lt;version&gt;20030825.184428&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;commons-pool&lt;/groupId&gt;
                  &lt;artifactId&gt;commons-pool&lt;/artifactId&gt;
                  &lt;version&gt;20030825.183949&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
                  &lt;artifactId&gt;eclipselink&lt;/artifactId&gt;
                  &lt;version&gt;2.3.0&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
                  &lt;artifactId&gt;javax.persistence&lt;/artifactId&gt;
                  &lt;version&gt;2.0.3&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
                  &lt;artifactId&gt;org.eclipse.persistence.jpa.modelgen.processor&lt;/artifactId&gt;
                  &lt;version&gt;2.3.0&lt;/version&gt;
                  &lt;scope&gt;provided&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;javax.annotation&lt;/groupId&gt;
                  &lt;artifactId&gt;jsr250-api&lt;/artifactId&gt;
                  &lt;version&gt;1.0&lt;/version&gt;
                  &lt;scope&gt;provided&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;jaxen&lt;/groupId&gt;
                  &lt;artifactId&gt;jaxen&lt;/artifactId&gt;
                  &lt;version&gt;1.1.3&lt;/version&gt;
              &lt;/dependency&gt;
  
              &lt;!-- Jersey dependency --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
                  &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
                  &lt;version&gt;1.13&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
                  &lt;artifactId&gt;jersey-bundle&lt;/artifactId&gt;
                  &lt;version&gt;1.13&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
                  &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
                  &lt;version&gt;1.13&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
                  &lt;artifactId&gt;jersey-multipart&lt;/artifactId&gt;
                  &lt;version&gt;1.13&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;com.sun.jersey.contribs&lt;/groupId&gt;
                  &lt;artifactId&gt;jersey-spring&lt;/artifactId&gt;
                  &lt;version&gt;1.13&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;cglib&lt;/groupId&gt;
                  &lt;artifactId&gt;cglib-nodep&lt;/artifactId&gt;
                  &lt;version&gt;2.1_3&lt;/version&gt;
              &lt;/dependency&gt;
              &lt;!-- Jersey dependency end --&gt;
          &lt;/dependencies&gt;
          &lt;properties&gt;
              &lt;org.springframework.version&gt;3.1.2.RELEASE&lt;/org.springframework.version&gt;
              &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
              &lt;project.build.finalName&gt;localito&lt;/project.build.finalName&gt;
              &lt;project.packaging&gt;war&lt;/project.packaging&gt;
              &lt;my.version&gt;1.0&lt;/my.version&gt;
          &lt;/properties&gt;
          &lt;name&gt;localito&lt;/name&gt;
      &lt;/project&gt;
  </code></pre>
  
  <p>I thank your help in advance.</p>