-->
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.  [ 1 post ] 
Author Message
 Post subject: Deploy EAR on JBoss shipping a newer version of HIBERNATE
PostPosted: Fri Sep 02, 2011 3:56 am 
Newbie

Joined: Fri Sep 02, 2011 3:47 am
Posts: 2
Hello,

I am having a hard time when trying to ship inside my EAR my own version of Hibernate (and not the one that JBoss brings by default).

To do it, I ship my Hibernate core and entitymanager packages inside the EAR, and try to isolate my classes from the JBoss' ones by making my deployment "scoped" including in the EAR a jboss-app.xml file containing the following:

Code:
<jboss-app>
  <loader-repository>com.example:archive=unique-archive-name
     <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
  </loader-repository>
</jboss-app>


As I want to use Hibernate through JPA, I declare my persistence provider in the persistence unit to be Hibernate, as follows:

Code:
<persistence>
   <persistence-unit name="myapp">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
   ...


But then, the worst happens. On deployment, the server throws a ClassCastException when it tries to cast from org.hibernate.ejb.HibernatePersistence to the JPA interface javax.persistence.spi.PersistenceProvider (which IS implimented by HibernatePersistence).

This is kind of WEIRD, because I am shipping the JPA API also in my EAR, so, given that the classes of the EAR have priority to those of JBoss, it should have no problem when casting from HibernatePersistence to PersistenceProvider, since they "should be" on the same class loader.
If I don't ship my own JPA API, then the deployment fails with a ClassNotFoundException when JBoss tries to find some JPA class.

Any idea on why is this casting failing?

I am using JBoss 5.1.0, and trying to use Hibernate 3.5.6.Final. The JPA API version is the one imported transitively by Maven through the menctioned Hibernate version.


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

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.