JBoss Community

Re: JBOSS 5.1 Server -> org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider

created by Fabio Schmitz Tani in Beginner's Corner - View the full discussion

Hello,

 

I've had similar problems, what I can tell you is that you can bundle your hibernate jars with your web application, and use a classloading configuration with jboss-web.xml to force JBoss to load jars from your application first, and then from common/lib, this way you can stop receiving this kinds of errors because of duplicate libraries that are bundled with JBoss.

 

The solution is documented here:

http://community.jboss.org/wiki/classloadingconfiguration

 

Here's the jist of it (jboss-web.xml inside your WAR WEB-INF folder)

 

 

<jboss-web>
   <class-loading java2ClassLoadingCompliance="false">
    <loader-repository>
        unique.packege.name:archive=your_project.war
        <loader-repository-config>
            java2ParentDelegation=false
        </loader-repository-config>
    </loader-repository>
   </class-loading>
</jboss-web>

 

With that you avoid conflicting problems, the one thing you might need is to update the hibernate-validator inside the common/lib, and unfortunately I wasn't able to get around this with this configuration. If no errors appear because of it, better for you, but if you get validation error messages, you will need to replace the current validator bundled with JBoss.

 

Best Regards,

Fabio

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community