I'm trying to write some unit tests for session beans with an in memory hsqldb, 
but cant get an instance of the EntityManagerFactory.

To simplify the situation and make sure I got all dependencies I set up a new 
EJB3 profiled project with JBoss IDE (dependencies from JBoss 4.0.5.GA) and 
wrote the following test code:

import javax.persistence.EntityManager;
  | import javax.persistence.EntityManagerFactory;
  | import javax.persistence.Persistence;
  | 
  | public class Test{
  |     public static void main(String[] args){
  |             EntityManagerFactory factory = 
Persistence.createEntityManagerFactory("test");
  |             EntityManager manager = factory.createEntityManager();
  |     }
  | }
  | 
persistence.xml is:

<?xml version="1.0" encoding="UTF-8"?>
  | <persistence>
  |    <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
  |    <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |         <properties>
  |         <property name="hibernate.connection.driver_class" 
value="com.mysql.jdbc.Driver"/>
  |         <property name="hibernate.connection.url" 
value="jdbc:mysql://localhost:3306/test"/>
  |         <property name="hibernate.connection.username" value="root"/>
  |         <property name="hibernate.connection.password" value=""/>
  |         <property name="hibernate.dialect" 
value="org.hibernate.dialect.MySQLDialect"/>
  |         <property name="hibernate.hbm2ddl.auto" value="create"/>
  |       </properties>
  |    </persistence-unit>
  | </persistence>

I have double checked that persistence.xml is on the classpath 
(META-INF/persistence.xml) and jdbc-driver is included.

Whatever I am trying I always get the following exception:

Exception in thread "main" javax.persistence.PersistenceException: No 
Persistence provider for EntityManager named test
  |     at 
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
  |     at 
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
  |     at Test.main(Test.java:9)


Can anyone help me out? Am I missing something?

Thanks

Goran

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3986368
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to