title: Spring 3 MVC: @Transactional added to Service class and now getting exception
body: <p>I am very new to spring and java. I have been using mostly springsource.org to try and work my way through creating a spring 3 MVC web application. I have it working where I can grab information and display it with the controllers and managers. </p>
  
  <p>Now I am working on the functionality to edit the information and save it back to the database. I added the <code>@Transactional</code> annotation to my save function inside my service class and now I am receiving an <code>UnsatisfiedDependencyException</code>. Being very new, I am not sure what to do to clear it. I added a bean for my EventsManager but I didn't think that would be necessary since Annotations were suppose to remove the need for extensive xml config files. I was not sure where the error is so I am posting my source code. Thank you for taking the time to assist me with my problem.</p>
  
  <p>Full Exception:</p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eventsController' defined in file [$Path\gov\mt\dphhs\epts\web\EventsController.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [gov.mt.dphhs.epts.services.EventsManager]: : No matching bean of type [gov.mt.dphhs.epts.services.EventsManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [gov.mt.dphhs.epts.services.EventsManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
  </code></pre>
  
  <p>Controller Class:</p>
  
  <pre><code>@Controller
  public class EventsController {
  
      private EventsManager eventsManager;
  
      @Autowired
      public EventsController(EventsManager eventsManager){
          this.eventsManager = eventsManager;
      }
  
      @RequestMapping("/events/events")
      public String displayEvents(ModelMap map){
  
          map.addAttribute("allEvents", eventsManager.getAllEvents());
  
          int totalEvents = eventsManager.getAllEvents().size();
          map.addAttribute("totalEvents",totalEvents);
  
          map.addAttribute("eventsTitle" , totalEvents + " Events");
  
          return "events";
      }
  
      @RequestMapping("/events/eventForm")
      public String editEvents(@RequestParam("id") Long eventId, ModelMap map){
  
          Events event = eventsManager.getEventById(eventId);
          map.addAttribute("pageTitle" , "Edit Event");
          map.addAttribute("event",event);
  
          return "eventForm";
      }
  
      @RequestMapping("/events/newEvent")
      public String newEvent(ModelMap map){
  
          Events event = new Events();
          map.addAttribute("pageTitle" , "New Event");
          map.addAttribute("event",event);
  
          return "eventForm";
      }
  
      @RequestMapping("/events/submitEvent")
      public String handleEventForm(@ModelAttribute("event")
              Events event, BindingResult result){
  
          System.out.println("Event Name:" + event.getEventName() + " ID: " + event.getEvntId());
  
          if(event.getEvntId() == null)
          {
              eventsManager.save(event);
          }
  
          return "redirect:/events/events";
      }   
  }
  </code></pre>
  
  <p>Service Class : </p>
  
  <pre><code>@Service("EventsManager")
  public class EventsManager implements IEventsManager {
  
  
      private EventsDAO eventsDao;
  
      @Autowired
      public void EventsDAO(EventsDAO eventsDao) {
          this.eventsDao = eventsDao;
      }
  
      public List&lt;Events&gt; getAllEvents() {
          return eventsDao.findAll();
      }
  
      public Events getEventById(Long id) {
  
          return eventsDao.findById(id);
      }
  
      public void delete(Events event) {
          // TODO Auto-generated method stub
  
      }
  
      @Transactional
      public void save(Events event) {
          eventsDao.save(event);
      }
  
      public Events update(Events event) {
  
          return eventsDao.update(event);
      }
  
  }
  </code></pre>
  
  <p>Trimmed down version of my Dao class:</p>
  
  <pre><code>public class EventsDAO implements IEventsDAO {
  
      @PersistenceContext
      private EntityManager em;
  
      protected final Log logger = LogFactory.getLog(EventsDAO.class);
  
      public void save(Events entity) {
          System.out.println("in Dao to save an event");
          logger.info("saving Events instance");
          try {
              em.persist(entity);
              logger.info("save successful");
          } catch (RuntimeException re) {
              logger.error("save failed", re);
              throw re;
          }
      }
  
      public EntityManager getEm() {
          return em;
      }
  
      public void setEm(EntityManager em) {
          this.em = em;
      }
  
      public static IEventsDAO getFromApplicationContext(ApplicationContext ctx) {
          return (IEventsDAO) ctx.getBean("EventsDAO");
      }
  }
  </code></pre>
  
  <p>Application Context : </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:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:p="http://www.springframework.org/schema/p"
  xmlns:tx="http://www.springframework.org/schema/tx"
  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/tx 
                      http://www.springframework.org/schema/tx/spring-tx.xsd"&gt;
  
  &lt;context:component-scan base-package="gov.mt.dphhs.epts" /&gt;
  
  &lt;bean id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="prefix" value="/WEB-INF/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceUnitName" value="EPTSTest3Pu" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  &lt;context:annotation-config /&gt;
  
  &lt;bean id="EventsManager" class="gov.mt.dphhs.epts.services.EventsManager" /&gt;
  
  &lt;bean id="SpecialGuestsDAO" class="gov.mt.dphhs.epts.repository.SpecialGuestsDAO" /&gt;
  
  &lt;bean id="GroupMembersDAO" class="gov.mt.dphhs.epts.repository.GroupMembersDAO" /&gt;
  
  &lt;bean id="GroupsDAO" class="gov.mt.dphhs.epts.repository.GroupsDAO" /&gt;
  
  &lt;bean id="EventNotificationsDAO" class="gov.mt.dphhs.epts.repository.EventNotificationsDAO" /&gt;
  
  &lt;bean id="EventListingsDAO" class="gov.mt.dphhs.epts.repository.EventListingsDAO" /&gt;
  
  &lt;bean id="EventGroupXrefDAO" class="gov.mt.dphhs.epts.repository.EventGroupXrefDAO" /&gt;
  
  &lt;bean id="EventsDAO" class="gov.mt.dphhs.epts.repository.EventsDAO" /&gt;
  </code></pre>
  
  <p></p>