JBoss comes with Hibernate 4 jars. The Hibernate Module is located in
C:\jboss-eap-6.1\modules\system\layers\base\org\hibernate\main
Jboss adds Hibernate if he detects the presence of an @PersistenceUnit, @PersistenceContext annotation, or a <persistence-unit-ref> or <persistence-context-ref> . So we don't need to declare dependency in the jboss-deployment-structure.xml.
But in my case, my application is using Hibernate 3.3, so I have errors in my Hibernate imports as Hibernate 3 differs from Hibernate 4. What to doooooo.
Ok, as I would like to use Hibernate 3 in different application, I prefer to create a new module in JBoss. But this time it will be easier as I have a Hibernate in my modules. So let's start:
javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'org.hibernate.ejb.HibernatePersistence' not found
And my module.xml associated is this one:
There is no need to add anything to jboss-dependency-structure.xml as it will be loaded implicitely.
In fact you should delete the provider from persistence.xml, which was org.hibernate.ejb.HibernatePersistence and add this line.
<property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />
The persistence.xml looks like this :
C:\jboss-eap-6.1\modules\system\layers\base\org\hibernate\main
Jboss adds Hibernate if he detects the presence of an @PersistenceUnit, @PersistenceContext annotation, or a <persistence-unit-ref> or <persistence-context-ref> . So we don't need to declare dependency in the jboss-deployment-structure.xml.
But in my case, my application is using Hibernate 3.3, so I have errors in my Hibernate imports as Hibernate 3 differs from Hibernate 4. What to doooooo.
Step1:
Create a folder named 3 under "C:\jboss-eap-6.1\modules\system\layers\base\org\hibernate\"Step2:
Working with Hibernate 3.3, I have downloaded it and put it in the directory 3 with the file module.xml. But I have an error :javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'org.hibernate.ejb.HibernatePersistence' not found
In fact 'org.hibernate.ejb.HibernatePersistence'
don’t exists at all in Hibernate 3.3, I have upgrated the application to use Hibernate3.6
and the error disappeared. So my hibernate/3 directory looks like this :
And my module.xml associated is this one:
Step3:
Make changes in the persistence.xmlIn fact you should delete the provider from persistence.xml, which was org.hibernate.ejb.HibernatePersistence and add this line.
<property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />
The persistence.xml looks like this :
The Session was the entry point for hibernate3. Session was obtained using JNDI lookup in earlier JBoss version. When using persistence.xml with EAP6, how did you get Session object? JNDI lookup or dependency injection?
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete