1 Reply Latest reply on Apr 5, 2007 11:02 AM by brucecoad

    TestNG, Eclipse and Database Connectivity Error

    brucecoad

      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.