I have a sample application that works fine as a plain old java project in Eclipse but when I set up a Maven project for it, I'm getting a "No Persistence provider for EntityManager named craigPersistenceUnit". My thought was that it was unable to find the META-INF/persistencce.xml file so I print out the classpath in the test. That prints out, among other things:
/C:/dev/eclipse/hibernate/SpringHibernateMaven/target/test-classes/
/C:/dev/eclipse/hibernate/SpringHibernateMaven/target/classes/
Just to be safe, I included those files in both the test and main directories and it does get copied over.
Just to close the loop here is my Spring config:Code:Directory of C:\dev\eclipse\hibernate\SpringHibernateMaven\target\classes\META-INF 01/14/2011 04:14 PM 1,150 persistence.xml 1 File(s) 1,150 bytes Directory of C:\dev\eclipse\hibernate\SpringHibernateMaven\target\test-classes\META-INF 01/14/2011 04:23 PM 1,152 persistence.xml 1 File(s) 1,152 bytes
And here is my persistence.xml:Code:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx" 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 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <context:component-scan base-package="craig.test" /> <context:property-placeholder location="classpath*:spring-config/*.properties" /> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> <property name="persistenceUnitName" value="craigPersistenceUnit" /> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> </beans>
Any thoughts on what is going on? Any suggestions for troubleshooting? Thanks.Code:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <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_2_0.xsd" version="2.0"> <persistence-unit name="craigPersistenceUnit" transaction-type="RESOURCE_LOCAL"> <properties> <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" /> <property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:XE" /> <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" /> <property name="hibernate.connection.username" value="findlaw" /> <property name="hibernate.connection.password" value="password" /> <property name="hibernate.default_schema" value="findlaw" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.current_session_context_class" value="thread" /> <property name="hibernate.hbm2ddl.auto" value="update" /> </properties> </persistence-unit> </persistence>
Craig


Reply With Quote
