title: Spring-MVC - Error creating bean with name 'procesarController': Injection of autowired dependencies failed
body: <p>I am having a problem with spring , when launching the app in the server I have this error message, please help Thanks in advance!!.</p>
  
  <p>Error Message</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'procesarController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zonagifts.web.service.TransaccionService com.zonagifts.web.controller.ProcesarController.transaccionService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TransaccionService' defined in file [C:\Users\Adolfo\Desktop\ZonacardEstableciemiento\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Webzonagifts\WEB-INF\classes\com\zonagifts\web\service\TransaccionServiceImpl.class]: Post-processing failed of bean type [class com.zonagifts.web.service.TransaccionServiceImpl] failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.zonagifts.web.service.TransaccionServiceImpl] for resource metadata: could not find class that it depends on
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779) [catalina.jar:7.0.27]
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273) [catalina.jar:7.0.27]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.27]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566) [catalina.jar:7.0.27]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556) [catalina.jar:7.0.27]
      at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_75]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_75]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_75]
      at java.lang.Thread.run(Thread.java:745) [na:1.7.0_75]
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zonagifts.web.service.TransaccionService com.zonagifts.web.controller.ProcesarController.transaccionService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TransaccionService' defined in file [C:\Users\Adolfo\Desktop\ZonacardEstableciemiento\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Webzonagifts\WEB-INF\classes\com\zonagifts\web\service\TransaccionServiceImpl.class]: Post-processing failed of bean type [class com.zonagifts.web.service.TransaccionServiceImpl] failed; nested exception is java.lang.IllegalStateException: Failed to introspect bean class [com.zonagifts.web.service.TransaccionServiceImpl] for resource metadata: could not find class that it depends on
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      ... 22 common frames omitted
  </code></pre>
  
  <p>My servlet.xml is</p>
  
  <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:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
          http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"&gt;
  
      &lt;context:component-scan base-package="com.zonagifts.web" &gt;
          &lt;context:include-filter type="aspectj" expression="com.zonagifts.*"/&gt;
      &lt;/context:component-scan&gt;
  
      &lt;!-- Enables the Spring MVC @Controller programming model --&gt;
      &lt;mvc:annotation-driven&gt;
          &lt;mvc:message-converters&gt;
              &lt;bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"&gt;
                  &lt;property name="objectMapper" ref="objectMapper" /&gt;
              &lt;/bean&gt;
          &lt;/mvc:message-converters&gt;
      &lt;/mvc:annotation-driven&gt;
  
  
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
  
      &lt;!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --&gt;
      &lt;mvc:resources mapping="/resources/**" location="/resources/" cache-period="604800" /&gt;
      &lt;mvc:view-controller path="/error" view-name="error" /&gt;
  
      &lt;bean id="viewResolver1"  class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="order" value="1" /&gt;
          &lt;property name="prefix" value="/WEB-INF/jsp/views/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  
      &lt;bean name="objectMapper" class="com.fasterxml.jackson.databind.ObjectMapper" /&gt;
  
  
      &lt;bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"&gt;
          &lt;property name="defaultLocale" value="es" /&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>My controller is </p>
  
  <pre><code>package com.zonagifts.web.controller;
  
  import javax.servlet.http.HttpSession;
  
  import org.apache.log4j.Logger;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.ResponseBody;
  import com.zonagifts.web.domain.ResponseServicio;
  import com.zonagifts.web.domain.Usuario;
  import com.zonagifts.web.service.TransaccionService;
  import com.zonagifts.web.util.Constantes;
  
  @Controller
  @RequestMapping("procesar")
  public class ProcesarController {
  
  
      @Autowired
      private TransaccionService transaccionService;
  
      private static Logger log = Logger.getLogger(LoginController.class);
  
      @RequestMapping(value="activar",method=RequestMethod.POST)
      public @ResponseBody ResponseServicio activarTarjeta(HttpSession sesion,String numeroTarjeta){
  
          ResponseServicio responseServicio=new ResponseServicio();
          Usuario usuario=(Usuario) sesion.getAttribute(Constantes.SESION_USUARIO_ZONA_CARDS);
          if(usuario != null){
              String [] respuesta=transaccionService.activarTarjeta(numeroTarjeta, usuario.getCodigoComercio(), usuario.getCodigoTerminal(), Constantes.TRANSACCION);
              responseServicio.setRespuesta(respuesta[0]);
              responseServicio.setCodigoOperacion(respuesta[1]);
              responseServicio.setMensaje(respuesta[2]);
          }
          return responseServicio;
      }
  
      @RequestMapping(value="anular",method=RequestMethod.POST)
      public @ResponseBody ResponseServicio anular(HttpSession sesion,String numeroTarjeta){
  
          ResponseServicio responseServicio=new ResponseServicio();
          Usuario usuario=(Usuario) sesion.getAttribute(Constantes.SESION_USUARIO_ZONA_CARDS);
          if(usuario != null){
              String [] respuesta=transaccionService.anularTarjeta(numeroTarjeta, usuario.getCodigoComercio(), usuario.getCodigoTerminal(), Constantes.TRANSACCION);
              responseServicio.setRespuesta(respuesta[0]);
              responseServicio.setCodigoOperacion(respuesta[1]);
              responseServicio.setMensaje(respuesta[2]);
          }
          return responseServicio;
      }
  
  
      @RequestMapping(value="consumo",method=RequestMethod.POST)
      public @ResponseBody ResponseServicio consumo(HttpSession sesion,String numeroTarjeta,String codigoSeguridad,String monto){
  
          ResponseServicio responseServicio=new ResponseServicio();
          Usuario usuario=(Usuario) sesion.getAttribute(Constantes.SESION_USUARIO_ZONA_CARDS);
          if(usuario != null){
              String [] respuesta=transaccionService.consumirSaldo(numeroTarjeta, codigoSeguridad, usuario.getCodigoComercio(), usuario.getCodigoTerminal(), monto, Constantes.TRANSACCION);
              responseServicio.setRespuesta(respuesta[0]);
              responseServicio.setCodigoOperacion(respuesta[1]);
              responseServicio.setMensaje(respuesta[2]);
              //responseServicio.setIdTransaccion(respuesta[3]);
          }
          return responseServicio;
      }
  
  
      @RequestMapping(value="saldo",method=RequestMethod.POST)
      public @ResponseBody ResponseServicio saldo(HttpSession sesion,String numeroTarjeta){
  
          ResponseServicio responseServicio=new ResponseServicio();
          Usuario usuario=(Usuario) sesion.getAttribute(Constantes.SESION_USUARIO_ZONA_CARDS);
          if(usuario != null){
              String [] respuesta=transaccionService.consultarSaldo(numeroTarjeta, usuario.getCodigoComercio(), usuario.getCodigoTerminal(), Constantes.TRANSACCION);
              responseServicio.setRespuesta(respuesta[0]);
              responseServicio.setCodigoOperacion(respuesta[1]);
              responseServicio.setMensaje(respuesta[2]);
          }
          return responseServicio;
      }
  
  }
  </code></pre>
  
  <p>TransactionServiceImpl</p>
  
  <pre><code>package com.zonagifts.web.service;
  
  import java.rmi.RemoteException;
  
  import org.apache.log4j.Logger;
  import org.springframework.stereotype.Service;
  import org.tempuri.GiftCardsSoapProxy;
  import com.zonagifts.api.util.Util;
  import com.zonagifts.web.controller.LoginController;
  
  @Service
  public class TransaccionServiceImpl implements TransaccionService {
  
      private static GiftCardsSoapProxy giftCardsSoapProxy; 
  
      private static Logger log = Logger.getLogger(LoginController.class);
  
      public String[] activarTarjeta(String numeroTarjeta, String codigoComercio,
              String codigoTerminal, String idTransaccion) {
  
          String token =tarjeta.concat(comercio).concat(terminal).concat(transaccion).concat(pass);
          Object response=null;
          try {
              giftCardsSoapProxy=new GiftCardsSoapProxy();
              response = giftCardsSoapProxy.activar_tarjeta(numeroTarjeta.trim(),
                      codigoComercio.trim(), codigoTerminal.trim(), 
                      idTransaccion.trim(), token);
  
          } catch (RemoteException e) {
  
              e.printStackTrace();
          }
          String[] res = (String[]) response;
          return res ;
      }
  
      public String[] anularTarjeta(String numeroTarjeta, String codigoComercio,
              String codigoTerminal, String idTransaccion) {
          String token =tarjeta.concat(comercio).concat(terminal).concat(transaccion).concat(pass);
          Object response=null;
          try {
              giftCardsSoapProxy=new GiftCardsSoapProxy();
              response = giftCardsSoapProxy.anular_tarjeta(numeroTarjeta.trim(),
                      codigoComercio.trim(), codigoTerminal.trim(), 
                      idTransaccion.trim(), token);
          } catch (RemoteException e) {
  
              e.printStackTrace();
          }
          String[] res = (String[]) response;
          //guardarTransaccionBD(tx);
          return res ;
      }
  
      public String[] consumirSaldo(String numeroTarjeta, String codigoSeguridad,
              String codigoComercio, String codigoTerminal, String montoConsumir,
              String idTransaccion) {
          String token =tarjeta.concat(codSeguridad).concat(comercio).concat(terminal).concat(monto).concat(transaccion).concat(pass);
          Object response=null;
          try {
              giftCardsSoapProxy=new GiftCardsSoapProxy();
              response = giftCardsSoapProxy.consumir_tarjeta(numeroTarjeta.trim(),
                      codigoSeguridad.trim(),codigoComercio.trim(), 
                      codigoTerminal.trim(),montoConsumir.trim(), idTransaccion.trim(), token);
          } catch (RemoteException e) {
  
              e.printStackTrace();
          }
          String[] res = (String[]) response;
          return res ;
      }
  
      public String[] consultarSaldo(String numeroTarjeta, String codigoComercio,
              String codigoTerminal, String idTransaccion) {
          String token =tarjeta.concat(comercio).concat(terminal).concat(transaccion).concat(pass);
          Object response=null;
          try {
              giftCardsSoapProxy=new GiftCardsSoapProxy();
              response = giftCardsSoapProxy.consultar_saldo(numeroTarjeta.trim(),
                      codigoComercio.trim(), codigoTerminal.trim(), 
                      idTransaccion.trim(), token);
          } catch (RemoteException e) {
  
              e.printStackTrace();
          }
  
          String[] res = (String[]) response;
          return res ;
      }
  
  
  
  }
  </code></pre>
  
  <p>TransaccionService</p>
  
  <pre><code>package com.zonagifts.web.service;
  
  public interface TransaccionService {
  
      String[] activarTarjeta(String numeroTarjeta,String codigoComercio,String codigoTerminal,String idTransaccion);
  
      String[] anularTarjeta(String numeroTarjeta,String codigoComercio,String codigoTerminal,String idTransaccion);
  
      String[] consumirSaldo(String numeroTarjeta,String codigoSeguridad,String codigoComercio,String codigoTerminal,String montoConsumir,String idTransaccion);
  
      String[] consultarSaldo(String numeroTarjeta,String codigoComercio,String codigoTerminal,String idTransaccion);
  
  }
  </code></pre>