I have used EJB 3.0 for about a month now in JBoss 4.0.3 RC's but I wanted to make just a small utility app for another purpose and decided to give Annotations, Entity Manager and Hibernate a shot in the J2SE. I recieve the following:
Code:
Sep 15, 2005 2:02:17 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1 beta 3
Sep 15, 2005 2:02:17 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Sep 15, 2005 2:02:17 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Sep 15, 2005 2:02:17 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
IWAV0052E Invocation Target Exception creating com.cowgar.learning.hibernate.HelloHibernate
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:86)
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named smarten
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:41)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
at com.cowgar.learning.hibernate.HelloHibernate.main(HelloHibernate.java:9)
... 5 more
My code is very simple:
Code:
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class HelloHibernate {
public static void main(String[] args) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("smarten");
EntityManager em = emf.createEntityManager();
Person p = new Person();
p.setName("Jeremy");
p.setPhone("555-1212");
em.persist(p);
em.close();
emf.close();
}
}
The persistence.xml:
Code:
<entity-manager>
<name>smarten</name>
<class>com.cowgar.learning.hibernate.Person</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.connection.username" value="john"/>
<property name="hibernate.connection.password" value="doe"/>
<property name="hibernate.connection.url" value="jdbc:postgresql:smart"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<!-- cache configuration -->
<property name="hibernate.ejb.classcache.org.hibernate.ejb.test.Item" value="read-write"/>
<property name="hibernate.ejb.collectioncache.org.hibernate.ejb.test.Item.distributors" value="read-write, RegionName"/>
</properties>
</entity-manager>
Any ideas as to what would cause this? I think I am following the manual on setting this up.
Thanks,
Jeremy