-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Classes not being read from persistence.xml?
PostPosted: Tue Jun 28, 2005 6:22 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
I am attempting to make use of the new EntityManager in a standalone application. I created the persistence.xml file listed below and put it in my META-INF directory. I know the file is being read because if I purposefully put invalid XML in it, it gives me an exception. Note, I don't have a .par file (don't know whether that's required or not) (it's just in a .jar file with the rest of my application). I'm receiving the exception listed below which indicates that I didn't specify any class files. I can get it to work if I specify hibernate.ejb.cfgfile and use a hibernate.cfg.xml file. Has anyone else run into this problem or know what I'm doing wrong?

Hibernate version: hibernate-3.1alpha1, hibernate-annotations-3.1beta3, hibernate-entitymanager-3.1beta1

Mapping documents:

persistence.xml
Code:
<?xml version="1.0"
   encoding="UTF-8"?>
<entity-manager>
   <name>bb_bb60</name>
   <class>edu.uchicago.at.blackboard.persistence.entity.CourseRole</class>
   <properties>
      <property name="hibernate.dialect"
         value="org.hibernate.dialect.Oracle9Dialect"/>
      <property name="hibernate.connection.driver_class"
         value="oracle.jdbc.driver.OracleDriver"/>
      <property name="hibernate.connection.url"
         value="jdbc:oracle:thin:@localhost:1522:BB60"/>
      <property name="hibernate.connection.username"
         value=""/>
      <property name="hibernate.connection.password"
         value=""/>
   </properties>
</entity-manager>


Code between sessionFactory.openSession() and session.close():

Code:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("bb_bb60");


Full stack trace of any exception that occurs:

Code:
Jun 28, 2005 5:06:53 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1alpha1
Jun 28, 2005 5:06:53 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Jun 28, 2005 5:06:53 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jun 28, 2005 5:06:53 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
javax.persistence.PersistenceException: org.hibernate.MappingException: Neither classes declared nor hibernate.cfg.xml file available
     at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:100)
     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:42)
     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:29)
     at edu.uchicago.at.blackboard.test.Test.main(Test.java:41)
Caused by: org.hibernate.MappingException: Neither classes declared nor hibernate.cfg.xml file available
     at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:136)
     at org.hibernate.ejb.HibernatePersistence.createFactory(HibernatePersistence.java:77)
     at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:93)
     ... 3 more


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 9:27 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There is a stupid bug, that mandate you to have at least 2 classes declared in your persistence.xml.
I fixed it in CVS together with class autodiscovery.
.par extension is not mandatory atm in your case, But it could change. Don't rely on that.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.