lundi 13 avril 2015

Maven dependencies in Tomcat

I'm fairly familiar with Spring but, I'm quite new to MVC. I have a project that has Module_Server, and Module_Web. Both are under Maven and both run individually, seemingly without problem. My issue concerns connecting them together. To be precise, I cannot autowire a Module_Server @Service component into a Module_Web controller. I repeat, without the autowired service component everything runs fine. However, when I autowire a service bean into my controllers, I get the following error:



Error creating bean with name 'CREATE_NEW_PLAYER_SERVICE': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.prussell.dao.PlayerDAO com.prussell.service.CreateNewPlayerService.playerDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'LOCATION_DAO': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.persistence.EntityManagerFactory] is defined


I've seen similar errors posted elsewhere on SO, but haven't managed to isolate my problem. My MVC module is really simple currently: here is the web.xml



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">

<display-name>Spring MVC Application</display-name>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:webApplicationContext.xml</param-value>
</context-param>
<!--<listener>-->
<!--<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>-->
<!--</listener>-->

<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<!--<welcome-file-list>-->
<!--<welcome-file>index.jsp</welcome-file>-->
<!--</welcome-file-list>-->

<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>


here is the dispatcher-servlet.xml



<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"
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">

<context:component-scan base-package="com.prussell" />

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>

</beans>

Aucun commentaire:

Enregistrer un commentaire