[jboss-user] [Beginners Corner] - TestNG, Eclipse and Database Connectivity Error

brucecoad do-not-reply at jboss.com
Thu Apr 5 08:14:49 EDT 2007


Hi There

I'm try to write a very basic test and run it from Eclipse, that gets a hook into a postgres database, but am getting the error 

"No Persistence provider for EntityManager named matches". 

Here is my test.

public class BasicTest {
  | 
  | 	private EntityManagerFactory emf;
  |    
  | 	@Test
  | 	public void test() throws Exception {
  | 		EntityManager em =   
  |                      getEntityManagerFactory().createEntityManager();
  |                 em.getTransaction().begin();
  |                 // Some code
  |                 em.close();
  | 	}	
  | 	
  |        public EntityManagerFactory getEntityManagerFactory() {
  |             return emf;
  |        }
  |     
  |       @Configuration(beforeTestClass=true)
  |        public void init() {
  |             emf = Persistence.createEntityManagerFactory("matches");
  |        }
  |     
  |        @Configuration(afterTestClass=true)
  |        public void destroy() {
  |           emf.close();
  |        }
  |     
  | }

My persistance.xml looks like this.

<persistence-unit name="matches">
  |       <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |       <jta-data-source>java:/matchesDatasource</jta-data-source>
  |       <properties>
  |          <property name="hibernate.hbm2ddl.auto" value="update"/>
  |          <property name="hibernate.show_sql" value="true"/>
  |          <property name="jboss.entity.manager.factory.jndi.name"  
  |                          value="java:/matchesEntityManagerFactory"/>
  |       </properties>
  | </persistence-unit>

And my components.xml has this piece of code.

<core:managed-persistence-context name="entityManager"
  |                persistence-unit-jndi-name="java:/matchesEntityManagerFactory"/>
  |      
  |     // Some standard Code          
  |    <core:entity-manager-factory persistence-unit-name="matches" 
  |              jndi-name="java:/matchesEntityManagerFactory" /> 
  |     	
  |    <core:ejb installed="@embeddedEjb@"/>
  |    // More standard code
  |   
Any advice would be appreciated. I've followed most of the tutorials that I could find, but must be doing something wrong. 
 
Thanks a lot.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4034983#4034983

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4034983



More information about the jboss-user mailing list