Results 1 to 9 of 9

Thread: begginers problem: persistence unit not found

Threaded View

  1. #1
    Join Date
    Jul 2008
    Location
    Darmstadt
    Posts
    6

    Unhappy [solved] begginers problem: persistence unit not found

    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

    Code:
    <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>
    persistence.xml have

    Code:
    <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>
    both, persistence.xml and applicationConfig.xml are in META-INF and in ClassPath

    UserDAOJPA looks like
    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);		
    	}
    
    }
    following libraries are in ClassPath:


    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
    Last edited by kumarunster; Jul 10th, 2008 at 08:15 AM. Reason: solved

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •