-->
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: Having more than one persistence.xml file on the classpath
PostPosted: Tue Jun 24, 2008 12:43 pm 
Newbie

Joined: Tue Jun 24, 2008 12:17 pm
Posts: 6
I was trying (still am, actually) to use Hibernate with JPA annotations for persisting simple POJOs to the db.
The complexity level is very similar to the Hello World tutorial.
So off I went and generated mapping annotations, persistence.xml file and a main class to handle the transactions.
All of this to fail on the first line of code:

EntityManagerFactory entityManagerFactory = Persistence
.createEntityManagerFactory("loggingLevels");

The failure is due to the fact that org.hibernate.ejb.Ejb3Configuration is picking up the wrong persistence.xml file for analyzing (from the activemq jar file, which is also on the class path). Since the persistence unit name noted in the main class does not appear in the other file - it just throws an error.

My persistence.xml is located next to my compiled classes under META_INF, just as required.

My question is - other than removing activemq jar file from the classpath - how can I make sure the correct persistence.xml file is being analized? (oh, yeah, and I've tried putting the META_INF on the top of the list of "order and export" in ecliipse and it did not make any difference.)

A few environment details (before the blob of the debug messages):
Hibernate 3.2
Hibernate Annotations 3.3.1
Hibernate Entity Manager 3.3.2
IDE - eclipse 3.3.2
activemq 5.1
VM - Java 1.6_0_06
OS - Windows XP 64bits
hardware - Dell, Intel core 2 quad cpu, 2.66GH, 3.93 GB of RAM


Here is the output to the console (after logging level was set to ALL):

0 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.3.1.GA
0 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.2.5
15 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
15 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : cglib
15 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
78 [main] INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.3.2.GA
94 [main] DEBUG org.hibernate.ejb.Ejb3Configuration - Look up for persistence unit: loggingLevels
94 [main] DEBUG org.hibernate.ejb.Ejb3Configuration - Analysing persistence.xml: jar:file:/C:/Documents%20and%20Settings/goren/My%20Documents/eclipse/workspace/common-libs/lib/active-mq/activemq-all-5.1.0.jar!/META-INF/persistence.xml
359 [main] DEBUG org.hibernate.ejb.packaging.PersistenceXmlLoader - Persistent Unit name from persistence.xml: activemq
359 [main] DEBUG org.hibernate.ejb.Ejb3Configuration - PersistenceMetadata [
name: activemq
jtaDataSource: null
nonJtaDataSource: null
transactionType: RESOURCE_LOCAL
provider: org.apache.openjpa.persistence.PersistenceProviderImpl
classes[
org.apache.activemq.store.jpa.model.StoredMessage org.apache.activemq.store.jpa.model.StoredSubscription org.apache.activemq.store.jpa.model.StoredMessageReference ]
packages[
]
mappingFiles[
]
jarFiles[
]
hbmfiles: 0
properties[
]]
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named loggingLevels
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
at nnl.util.logging.upload.UploadDataIntoLoggingTables.main(UploadDataIntoLoggingTables.java:37)


Top
 Profile  
 
 Post subject: mia culpa: typed META-INF instead of META_INF
PostPosted: Wed Jun 25, 2008 3:13 pm 
Newbie

Joined: Tue Jun 24, 2008 12:17 pm
Posts: 6
For all of you who took of their time to read my posting - thousands of apologies, this was all my fault due to a tiny typo I managed to discover today (finally!). Of course Hibernate picked up the wrong persistence.xml file - I was not careful enough to put it in META-INF, should ease up on the shift key next time so as to get the hyphen and not the underscore.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 9:40 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Sometimes the simplest problems are the toughest to find. We all feel your pain. :(

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.