Hi all,
i have a problem with hibernate-jpa integration with spring. I have searched the forum, but no explicit answer found for the problem
The problem is following:
Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name 'pmanager' found
I use the simpliest configuration for jpa, that is described in spring-reference.pdf: LocalEntityManagerFactoryBean
my applicationConfig.xml shows as
persistence.xml haveCode:<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> <property name="persistenceUnitName" value="pmanager" /> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory"> <ref local="entityManagerFactory" /> </property> </bean> <bean id="userDAO" class="test_spring.dao.jpa.UserDAOJPA"> <property name="entityManagerFactory"> <ref local="entityManagerFactory" /> </property> </bean>
both, persistence.xml and applicationConfig.xml are in META-INF and in ClassPathCode:<persistence-unit name="pmanager"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" /> <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:appfuse" /> <property name="hibernate.connection.username" value="sa" /> <property name="hibernate.connection.password" value="" /> <property name="hibernate.dialect" value="net.sf.hibernate.dialect.HSQLDialect" /> <property name="hibernate.hbm2ddl.auto" value="create" /> </properties> </persistence-unit>
UserDAOJPA looks like
following libraries are in ClassPath:Code:public class UserDAOJPA extends JpaDaoSupport implements UserDAO { public User getUser(Long userId) { return (User)getJpaTemplate().find(User.class, userId); } public List getUsers() { return getJpaTemplate().find("from User"); } public void removeUser(Long userId) { Object user = getJpaTemplate().find(User.class, userId); getJpaTemplate().remove(user); } public void saveUser(User user) { getJpaTemplate().persist(user); } }
antlr
asm
asm-attrs
sglib
commons-collections
commons-logging
commons-lang
dom4j
ejb3-persistence
hibernate3
hibernate-annotations
hibernate-commons-annotations
hibernate-entitymanager
hsqldb
jta
log4j
spring
have somebody any idea, how i can solve this problem?
many thanks and best regards,
Nikolai


Reply With Quote
