title: Spring @Autowired of @Service classes works on Tomcat but not Resin
body: <p>I have a 100% working solution in Tomcat 8.0.20 packaged as a WAR using Spring restful services and spring core libraries.</p>
  
  <p>When I take the same WAR and drop it into Resin 4.0.36 (and also 4.0.43) my @Autowired @Services are not recognized whatsoever.  </p>
  
  <p>This leads me to believe that there is an environmental difference between Tomcat and Resin.  Do I need to set some property or reference something explicitly to make the WAR work on Resin?</p>
  
  <pre><code>    2015-03-30 17:26:25 WARN  XmlWebApplicationContext:487 - Exception    
  encountered during context initialization - cancelling refresh attempt
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userInfoWebService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ca.abcc.service.user.UserService ca.abcc.controller.webservice.UserInfo.UserInfoWebService.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ca.abcc.service.user.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
  at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663)
  at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629)
  at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677)
  at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548)
  at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489)
  at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
  at javax.servlet.GenericServlet.init(GenericServlet.java:70)
  at com.caucho.server.dispatch.ServletConfigImpl.createServletImpl(ServletConfigImpl.java:1358)
  at com.caucho.server.dispatch.ServletConfigImpl.createServlet(ServletConfigImpl.java:1254)
  at com.caucho.server.dispatch.ServletConfigImpl.createServlet(ServletConfigImpl.java:1205)
  at com.caucho.server.dispatch.ServletManager.init(ServletManager.java:251)
  at com.caucho.server.webapp.WebApp.startImpl(WebApp.java:3777)
  at com.caucho.server.webapp.WebApp.access$700(WebApp.java:208)
  at com.caucho.server.webapp.WebApp$StartupTask.run(WebApp.java:5297)
  at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173)
  at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118)
  Caused by: org.springframework.beans.factory.BeanCreationException: Could   
  not autowire field: private ca.abcc.service.user.UserService 
  ca.abcc.controller.webservice.UserInfo.UserInfoWebService.userService; 
  nested exception is 
  org.springframework.beans.factory.NoSuchBeanDefinitionException: No 
  qualifying bean of type [ca.abcc.service.user.UserService] found for 
  dependency: expected at least 1 bean which qualifies as autowire candidate 
  for this dependency. Dependency annotations: 
  {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostPr
  ocessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
  at 
  org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
  ... 26 more
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:    
  No qualifying bean of type [ca.abcc.service.user.UserService] found 
  for dependency: expected at least 1 bean which qualifies as autowire 
  candidate for this dependency. Dependency annotations: 
  {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  at 
   org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
  ... 28 more
  2015-03-30 17:26:25 ERROR DispatcherServlet:497 - Context initialization failed
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userInfoWebService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private ca.abcc.service.user.UserService ca.abcc.controller.webservice.UserInfo.UserInfoWebService.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ca.abcc.service.user.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
  {resin-50} WebApp[production/webapp/default/Impact.Auto.Online.Buyer.Portal] fail
  [15-03-30 17:26:25.294] {resin-15} org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [ca.impactauto.service.user.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
                      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301)
                      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
                      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
                      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
                      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
                      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
                      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
                      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
                      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
                      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
                      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
                      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
                      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
                      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
                      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
                      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
                      at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663)
                      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629)
                      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677)
                      at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548)
                      at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489)
                      at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
                      at javax.servlet.GenericServlet.init(GenericServlet.java:70)
                      at com.caucho.server.dispatch.ServletConfigImpl.createServletImpl(ServletConfigImpl.java:1358)
                      at com.caucho.server.dispatch.ServletConfigImpl.createServlet(ServletConfigImpl.java:1254)
                      at com.caucho.server.dispatch.ServletConfigImpl.createServlet(ServletConfigImpl.java:1205)
                      at com.caucho.server.dispatch.ServletManager.init(ServletManager.java:251)
                      at com.caucho.server.webapp.WebApp.startImpl(WebApp.java:3777)
                      at com.caucho.server.webapp.WebApp.access$700(WebApp.java:208)
                      at com.caucho.server.webapp.WebApp$StartupTask.run(WebApp.java:5297)
                      at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173)
                      at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118)
  </code></pre>
  
  <p>Dispatcher Servlet:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"  
  xmlns:context="http://www.springframework.org/schema/context"  
  xmlns:p="http://www.springframework.org/schema/p"   
  xmlns:mvc="http://www.springframework.org/schema/mvc"   
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  xsi:schemaLocation="http://www.springframework.org/schema/beans  
  http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
  http://www.springframework.org/schema/context  
  http://www.springframework.org/schema/context/spring-context-4.0.xsd  
  http://www.springframework.org/schema/mvc  
  http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd 
  "&gt;  
  
  &lt;mvc:annotation-driven /&gt;
  &lt;!-- &lt;mvc:default-servlet-handler/&gt;--&gt;
  &lt;!-- &lt;context:annotation-config /&gt;--&gt;
  &lt;context:component-scan base-package="ca.xyz.controller" /&gt;
  &lt;context:annotation-config /&gt;
  
  &lt;bean id="viewResolver"    
  class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;!-- &lt;property name="viewClass" 
  value="org.springframework.web.servlet.view.JstlView" /&gt;--&gt;
      &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="messageSource" 
  class="org.springframework.context.support.ResourceBundleMessageSource"&gt;
      &lt;property name="basename" value="messages"/&gt;
  &lt;/bean&gt;
  
  &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt;
  
  &lt;mvc:view-controller path="/" view-name="welcome"/&gt;
  
  &lt;/beans&gt;
  </code></pre>