Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: HibernateEntityManager 3.1 beta 7
Mapping documents:
Persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
<persistence-unit name="testDB" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.jboss.tutorial.entity.bean.Order</class>
<class>org.jboss.tutorial.entity.bean.LineItem</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.connection.username" value="radien"/>
<property name="hibernate.connection.password" value="radien"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@172.25.203.148:1521:radien"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
<property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/>
</properties>
</persistence-unit>
</persistence>
Code between sessionFactory.openSession() and session.close():
Client.java
emf = Persistence.createEntityManagerFactory("testDB");
if(emf==null){
System.out.println("Got Entity manager factory as null");
}
EntityManager em = emf.createEntityManager();
//private Order order;
/*
Client client=new Client();
if (client.order == null) client.order = new Order();
client.order.addPurchase("Memory stick", 2, 500.00);
*/
em.close();
emf.close();
Full stack trace of any exception that occurs:
run:
[java] INFO 04-05 20:23:25,059 (Environment.java:<clinit>:495) -Hibernate
3.2 cr1
[java] INFO 04-05 20:23:25,090 (Environment.java:<clinit>:528) -hibernate
.properties not found
[java] INFO 04-05 20:23:25,106 (Environment.java:buildBytecodeProvider:662
) -Bytecode provider name : cglib
[java] INFO 04-05 20:23:25,121 (Environment.java:<clinit>:579) -using JDK
1.4 java.sql.Timestamp handling
[java] Exception in thread "main" java.lang.NoClassDefFoundError: build/cla
sses/org/jboss/tutorial/entity/bean/Order (wrong name: org/jboss/tutorial/entity
/bean/Order)
[java] at java.lang.ClassLoader.defineClass1(Native Method)
[java] at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
[java] at java.security.SecureClassLoader.defineClass(SecureClassLoader
.java:124)
[java] at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
[java] at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
[java] at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.j
ava:110)
[java] at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configur
ation.java:707)
[java] at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(
Ejb3Configuration.java:778)
[java] at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactor
y(Ejb3Configuration.java:640)
[java] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactor
y(Ejb3Configuration.java:528)
[java] at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configu
ration.java:126)
[java] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactor
y(Ejb3Configuration.java:180)
[java] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFac
tory(HibernatePersistence.java:110)
[java] at javax.persistence.Persistence.createEntityManagerFactory(Pers
istence.java:37)
[java] at org.jboss.tutorial.entity.client.Client.main(Client.java:48)
[java] Java Result: 1
Name and version of the database you are using:Oracle 9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hi all,
I am new to this hibernate entity manager thing.I am trying to use hibernate entity manager in J2SE environment.I am trying to create entity manager factory from my client program.While i am running the client it is showing the class def not found error i.e it is failing to find the
entity classes.The folder that contains the classes is also in the classpath.
I am unable to figure out why this error is occuring .Please help me in solving the issue.
Thank You.