title: cannot access to annotated spring service
body: <p>I'm trying to access @Service defined class</p>
  
  <p>Interfaces are defined, here is an implementation </p>
  
  <pre><code>    @Service
      public class TypeServiceImpl implements TypeService {
  
          @Autowired
          TypeDAO dao;
  
          public List&lt;DocType&gt; findAll() {
      System.out.println("accessing findAll"); //have no appearence
      return dao.findAll();
  }
  </code></pre>
  
  <p>public TypeDAOImpl()
      {
          System.out.println("Constructing TypeDAOImpl");
      }</p>
  
  <pre><code>...
  
  }
  </code></pre>
  
  <p>code for DAO:</p>
  
  <pre><code>@Repository
  public class TypeDAOImpl extends BaseDAO&lt;Type, Long&gt; implements TypeDAO{
  
  }
  </code></pre>
  
  <p>BaseDAO:</p>
  
  <pre><code>public class BaseDAO&lt;T, ID extends Serializable&gt; extends GenericDAOImpl&lt;T, ID&gt; {
  
      @Autowired
      @Override
      public void setSessionFactory(SessionFactory sessionFactory) {
          super.setSessionFactory(sessionFactory);
      }
  }
  </code></pre>
  
  <p>used <a href="http://code.google.com/p/hibernate-generic-dao/" rel="nofollow noreferrer">generic dao</a>
  configuration for app loads fine(no warn or err), but when I'm trying to use service:</p>
  
  <pre><code>@Autowired
  private TypeService TypeService;
  public void init() {
  
          try {
              for (Type d : TypeService.findAll()) {
                  System.out.println(d.getType());
              }
          } catch (Exception e) {
              e.printStackTrace();
          }
  }
  </code></pre>
  
  <p>in applicationContext:</p>
  
  <pre><code>&lt;!-- Use annotations (@Autowired) for property injection --&gt;
      &lt;context:annotation-config /&gt;
  </code></pre>
  
  <p>in logs:
  INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@14db0e3: ... typeDAOImpl,appMain, typeServiceImpl</p>
  
  <p>my web.xml</p>
  
  <pre><code>&lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;classpath:/config/application-context.xml,classpath:/config/datasource-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;description&gt;
      Vaadin production mode&lt;/description&gt;
          &lt;param-name&gt;productionMode&lt;/param-name&gt;
          &lt;param-value&gt;false&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;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.request.RequestContextListener&lt;/listener-class&gt;
      &lt;/listener&gt; 
       &lt;servlet&gt;
          &lt;servlet-name&gt;My Application&lt;/servlet-name&gt;
          &lt;servlet-class&gt;com.vaadin.terminal.gwt.server.ApplicationServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;description&gt;
          Vaadin application class to start&lt;/description&gt;
              &lt;param-name&gt;application&lt;/param-name&gt;
              &lt;param-value&gt;myapp.main.MainApp&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;My Application&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  ...
  </code></pre>
  
  <p>stack trace is "very informational" (I used vaadin as web framework)</p>
  
  <p>java.lang.NullPointerException
      at main.AppMain.init(AppMain.java:26)
      at com.vaadin.Application.start(Application.java:497)
      at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1001)
      at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:411)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
      at java.lang.Thread.run(Unknown Source)</p>
  
  <p>Any suggestions?</p>
  
  <p>I added constructors for GenericDAOHibernate and TypeDAOImpl, so as I understand, these beans are initialized
  ...
  12.10.2009 12:57:48 org.hibernate.impl.SessionFactoryImpl 
  INFO: building session factory
  12.10.2009 12:57:48 org.hibernate.impl.SessionFactoryObjectFactory addInstance
  INFO: Not binding factory to JNDI, no JNDI name configured
  <strong>Constructing Generic DAO
  Constructing TypeDAOImpl</strong>
  12.10.2009 12:57:48 org.springframework.web.context.ContextLoader initWebApplicationContext
  ...</p>
  
  <p>I don't understand because this config worked with ZK..</p>