Problème avec le persistence.xml
Bonjour, alors j'ai un petit problème avec mon projet et jpa. J'ai cette belle erreur :
[ERROR] context.ContextLoader Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'showDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFact
ory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: No persistence units parsed from {classpath*:META-INF/persistence.xml}
J'ai un peu cherché partout et a priori ce serait parce qu'il ne trouve pas le persistence.xml, mais j'ai un peu tout essaye. Donc il est dans src/META-INF qui est dans le classpath. Après, je lance mon appli avec maven, donc çà donne mvn tomcat:run
alors voilà la tête de mon persistence.xml (rien de bien exceptionnel :) )
Code:
1 2 3 4 5 6
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="SpringJpaGettingStarted" transaction-type="RESOURCE_LOCAL"/>
</persistence> |
et dans mon applicationContext.xml, rien de bien froufrou non plus :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <bean id="showDao" class="org.apache.tapestry5.series.dao.ShowDAOImpl">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="persistenceXmlLocations">
<list>
<value>classpath*:META-INF/persistence.xml</value>
</list>
</property>
<property name="defaultDataSource" ref="dataSource"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceUnitManager" ref="persistenceUnitManager" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true"/>
<property name="database" value="MYSQL"/>
<property name="generateDdl" value="true"/>
<property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
</bean>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/series"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
<property name="dataSource" ref="dataSource"/>
</bean> |
Je ne vois plus trop quoi faire :cry: si quelqu'un a une idée je suis preneur