I'm trying to access @Service defined class
Interfaces are defined, here is an implementation
@Service
public class TypeServiceImpl implements TypeService {
@Autowired
TypeDAO dao;
public List<DocType> findAll() {
System.out.println("accessing findAll"); //have no appearence
return dao.findAll();
}
public TypeDAOImpl() { System.out.println("Constructing TypeDAOImpl"); }
...
}
code for DAO:
@Repository
public class TypeDAOImpl extends BaseDAO<Type, Long> implements TypeDAO{
}
BaseDAO:
public class BaseDAO<T, ID extends Serializable> extends GenericDAOImpl<T, ID> {
@Autowired
@Override
public void setSessionFactory(SessionFactory sessionFactory) {
super.setSessionFactory(sessionFactory);
}
}
used generic dao configuration for app loads fine(no warn or err), but when I'm trying to use service:
@Autowired
private TypeService TypeService;
public void init() {
try {
for (Type d : TypeService.findAll()) {
System.out.println(d.getType());
}
} catch (Exception e) {
e.printStackTrace();
}
}
in applicationContext:
<!-- Use annotations (@Autowired) for property injection -->
<context:annotation-config />
in logs: INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@14db0e3: ... typeDAOImpl,appMain, typeServiceImpl
my web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/config/application-context.xml,classpath:/config/datasource-context.xml</param-value>
</context-param>
<context-param>
<description>
Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>My Application</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
<description>
Vaadin application class to start</description>
<param-name>application</param-name>
<param-value>myapp.main.MainApp</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>My Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
...
stack trace is "very informational" (I used vaadin as web framework)
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)
Any suggestions?
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 Constructing Generic DAO Constructing TypeDAOImpl 12.10.2009 12:57:48 org.springframework.web.context.ContextLoader initWebApplicationContext ...
I don't understand because this config worked with ZK..