Reputation: 4224
I am totally new to Spring framework, bean injections etc, and working on a project organized in many sub-projects about it.
In the commons subproject, containing all Entities, DAOs, DS, I have a MyDS
class implementing IMyDS
and containing its EntityManager and DAO :
@PersistenceContext(unitName="myPersistenceUnit")
private EntityManager entityManager;
@Autowired
@Qualifier("myDAO")
private IMyDAO mainDao;
Then, I am trying to call this class from the Web part of my project, like this:
@Autowired
private IMyDS myDS;
// then I try to call a function of IMyDS, and get an error at this line :
protected ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ReefPresentationException {
myDS.callFunction(form);
}
But it doesn't work, giving me a NullPointerException. So far I've guessed the bean is not correctly injected, so I tried to add some information in my application-context-spring.xml
file :
<bean id="myDS" class="com.my.project.service.IMyDS" />
And I get this error :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myDS' defined in ServletContext resource [/WEB-INF/config/application-context-spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.my.project.service.IMyDS]: Specified class is an interface
So I tried instead to declare the class :
<bean id="myDS" class="com.my.project.service.internal.MyDS" />
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myDS' defined in ServletContext resource [/WEB-INF/config/application-context-spring.xml]: Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
So I really have no idea of what is wrong right now...
Thanks for your help
Upvotes: 0
Views: 1512
Reputation: 1572
The errors says it all. You have defined your interface IMyDS as a bean and Spring can't instantiate the interface.
Upvotes: 1