-->
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.  [ 3 posts ] 
Author Message
 Post subject: Initial attempts to use EntityManager can't find PAR
PostPosted: Wed Nov 16, 2005 9:20 pm 
Newbie

Joined: Wed Nov 16, 2005 9:03 pm
Posts: 2
I'm running out of Eclipse, and I've moved the PAR file all over the place to make sure it was in the CLASSPATH.

At this point I'm not entirely sure if the classpath is the problem. Most of my code and configuration is right out of the User Guide.



Hibernate version:
EntityManager 3.1 beta 4

Mapping documents:
persistence.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<entity-manager>
   <name>MediciEntity</name>
   <jta-data-source>java:/MediciDS</jta-data-source>
   <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
      <property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>
   </properties>   
</entity-manager>

This file is in the META-INF directory of a PAR file with the Annotated classes. The classes with their annotations have been working with an
AnnotationConfiguration. However, I'm now trying to load them using the
EntityManager API.


Code between sessionFactory.openSession() and session.close():
Code:
        Properties properties = new Properties();
        EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("MediciEntity",properties);
        EntityManager manager = emfactory.createEntityManager();
       
       
        manager.close();
        emfactory.close();


The properties hash is currently empty.


Full stack trace of any exception that occurs:
Code:
2005-11-16 19:59:05,468 (INFO ) cfg.Environment - Hibernate 3.1 rc2
2005-11-16 19:59:05,468 (INFO ) cfg.Environment - hibernate.properties not found
2005-11-16 19:59:05,468 (INFO ) cfg.Environment - using CGLIB reflection optimizer
2005-11-16 19:59:05,468 (INFO ) cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
2005-11-16 19:59:05,531 (DEBUG) ejb.Ejb3Configuration - Trying to find persistence unit: MediciEntity
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named MediciEntity
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:41)
   at org.ccf.Medici.Accountant.main(Accountant.java:150)


Top
 Profile  
 
 Post subject: Okay I got past that problem though not by the book
PostPosted: Wed Nov 16, 2005 10:01 pm 
Newbie

Joined: Wed Nov 16, 2005 9:03 pm
Posts: 2
I placed the persistence.xml into an META-INF directory in my Eclipse source folder which copied it automatically to the classes folder. The Persistence object apparently assumes the persistence.xml is in the same JAR file as the executing code rather than in the PAR file.

It doesn't seem to jive with the documentation, but I'm not complaining since I expect to move the whole thing under JBOSS EJB container eventually.

Under the container senario does the persistence.XML go in the EJB bean's META-INF, the EAR META-INF or the PAR?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 8:43 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Eclipse does something weird I'd say.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.