I’m struggling with JBOss and I’m stuck on a problem which seems trival to fix but it turns out I can’t.
When I try to deploy a simple java web app I encounter an exception:
org.hibernate.ejb.HibernatePersistence cannot be cast to avax.persistence.spi.PersistenceProvider
I know that this is a problem with having more then one persistence.jar. So in my pom I did something like that:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
</exclusion>
</dependency>
But I’m unlucky with it. I still get the error. Could anybody help me kindly to solve this task?
Agata
It looks like you want to package your own version of Hibernate within your application. This is possible but you’ll have to setup classloader scoping for your application. From ClassLoadingConfiguration:
In other words, either include all your Hibernate libraries and disable parent class loader delegation or exclude them all and use the one from JBoss.
See also