Hibernate 3.6 issue with JBoss EAP 6.1.0 Final
mattso Feb 11, 2014 6:44 PMWe have several applications deploys on JBoss AS, and each uses different version of hibernate.
Therefore, we created several slot for hibernate under modules
- <JBOSS_HOME>/home/com/company/3party/hibernate/main (version 3.0)
- <JBOSS_HOME>/home/com/company/3party/hibernate/3.2
- <JBOSS_HOME>/home/com/company/3party/hibernate/3.6
One of the application contains EJB that uses JPA and Hibernate 3.6, and we did the following declaration:
1) Declare exclusions of JBoss AS hibernate and JPA + include Hibernate 3.6 module dependency in EAR's jboss-deployment-descriptor.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<exclusions>
<module name="org.hibernate"/>
<module name="org.jboss.as.jpa"/>
...
</exclusions>
<dependencies>
<module name="com.company.3party.hibernate" slot="3.6"/>
...
</dependencies>
</deployment>
<sub-deployment name="inspect-ejb.jar">
<exclusions>
<module name="org.hibernate"/>
<module name="org.jboss.as.jpa"/>
...
</exclusions>
<dependencies>
<module name="com.company.3party.hibernate" slot="3.6"/>
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
2) Under EJB's persistence.xml, declare provideModule and disable 2nd cache
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="Aungate-EDD">
<jta-data-source>java:/jboss/datasources/DSDDefaultDS</jta-data-source>
<class>com.company.inspection.domain.Export</class>
...
<mapping-file>META-INF/orm.xml</mapping-file>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.connection.release_mode" value="after_statement" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
<property name="hibernate.cache.use_second_level_cache" value="false" />
<!-- <property name="jboss.as.jpa.providerModule" value="com.company.company.hibernate:3.6" /> This did not work so commented out -->
<property name="jboss.as.jpa.providerModule" value="hibernate3-bundled" />
</properties>
</persistence-unit>
</persistence>
3) I disabled infinitspan sub-system (I uses standalone full profile) because I see that uses Hiberante 4.
I want to avoid any protential class loading issue.
When I start up JBoss AS to deploy the EAR, I see that:
...
...
2014-02-11 17:11:16,564 DEBUG [org.jboss.modules] Module org.hibernate:main defined by local module loader @b1f3c4e (finder: local module fi
nder @2fb02a96 (roots: /opt/jboss.8090/modules,/opt/jboss.8090/modules/system/layers/base))
...
...
2014-02-11 17:11:16,940 DEBUG [org.jboss.modules] Module org.jboss.as.jpa.hibernate:4 defined by local module loader @b1f3c4e (finder: local
module finder @2fb02a96 (roots: /opt/jboss.8090/modules,/opt/jboss.8090/modules/system/layers/base))
...
...
2014-02-11 17:11:16,973 DEBUG [org.jboss.as.jpa] loaded persistence provider adapter org.jboss.as.jpa.hibernate:4
...
...
2014-02-11 17:11:20,554 INFO [org.jboss.as.server.deployment] JBAS015876: Starting deployment of "null" (runtime-name: "inspect.war")
2014-02-11 17:11:20,557 INFO [org.jboss.as.server.deployment] JBAS015876: Starting deployment of "null" (runtime-name: "inspect-ejb.jar"
)
...
...
2014-02-11 17:11:21,573 DEBUG [org.jboss.as.jpa] added org.jboss.as.jpa:main dependency to inspect.ear
2014-02-11 17:11:21,573 DEBUG [org.jboss.as.jpa] added org.jboss.as.jpa.spi:main dependency to inspect.ear
...
...
2014-02-11 17:11:21,584 DEBUG [org.jboss.modules] Module org.jboss.as.jpa.hibernate:3 defined by local module loader @b1f3c4e (finder: local
module finder @2fb02a96 (roots: /opt/jboss.8090/modules,/opt/jboss.8090/modules/system/layers/base))
2014-02-11 17:11:21,591 DEBUG [org.jboss.modules] Module org.hibernate:3 defined by local module loader @b1f3c4e (finder: local module finde
r @2fb02a96 (roots: /opt/jboss.8090/modules,/opt/jboss.8090/modules/system/layers/base))
...
...
2014-02-11 17:11:21,602 DEBUG [org.jboss.as.jpa] added org.jboss.as.jpa:main dependency to inspect-ejb.jar
2014-02-11 17:11:21,603 DEBUG [org.jboss.as.jpa] added org.jboss.as.jpa.spi:main dependency to inspect-ejb.jar
...
...
2014-02-11 17:11:21,626 DEBUG [org.jboss.as.server.deployment] Adding dependency ModuleDependency [identifier=com.company.3party.hibernate:3.
6, moduleLoader=local module loader @b1f3c4e (finder: local module finder @2fb02a96 (roots: /opt/jboss.8090/modules,/opt/jboss.8090/modules/
system/layers/base)), export=false, optional=false, importServices=true] to module deployment.inspect.ear:main
...
...
2014-02-11 17:11:21,630 DEBUG [org.jboss.as.server.deployment] Adding dependency ModuleDependency [identifier=com.company.3party.hibernate:3.
6, moduleLoader=Service Module Loader, export=false, optional=false, importServices=false] to module deployment.inspect.ear:main
...
...
2014-02-11 17:11:21,654 DEBUG [org.jboss.as.server.deployment] Adding dependency ModuleDependency [identifier=com.company.3party.hibernate:3.
6, moduleLoader=local module loader @b1f3c4e (finder: local module finder @2fb02a96 (roots: /opt/jboss.8090/modules,/opt/jboss.8090/modules/
system/layers/base)), export=false, optional=false, importServices=true] to module deployment.inspect.ear.inspect-ejb.jar:main
...
...
2014-02-11 17:11:21,659 DEBUG [org.jboss.as.server.deployment] Adding dependency ModuleDependency [identifier=com.company.3party.hibernate:3.
6, moduleLoader=Service Module Loader, export=false, optional=false, importServices=false] to module deployment.inspect.ear.inspect-ej
b.jar:main
...
...
2014-02-11 17:11:21,696 DEBUG [org.jboss.as.server.deployment] Adding dependency ModuleDependency [identifier=com.company.3party.hibernate:3.
6, moduleLoader=local module loader @b1f3c4e (finder: local module finder @2fb02a96 (roots: /opt/jboss.8090/modules,/opt/jboss.8090/modules/
system/layers/base)), export=false, optional=false, importServices=true] to module deployment.inspect.ear.inspect.war:main
...
...
2014-02-11 17:11:21,704 DEBUG [org.jboss.as.server.deployment] Adding dependency ModuleDependency [identifier=com.company.3party.hibernate:3.
6, moduleLoader=Service Module Loader, export=false, optional=false, importServices=false] to module deployment.inspect.ear.inspect.wa
r:main
...
...
2014-02-11 17:11:22,071 DEBUG [org.jboss.modules] Module com.company.3party.hibernate:3.6 defined by local module loader @b1f3c4e (finder: lo
cal module finder @2fb02a96 (roots: /opt/jboss.8090/modules,/opt/jboss.8090/modules/system/layers/base))
...
...
2014-02-11 17:11:23,830 DEBUG [org.jboss.as.jpa] loaded persistence provider adapter org.jboss.as.jpa.hibernate:4
2014-02-11 17:11:23,832 DEBUG [org.jboss.as.jpa] Adding dependency on PU service service jboss.persistenceunit."inspect.ear/inspect-ej
b.jar#Client-EDD" for component com.company.inspect.client.edd.ClientManagerImpl
...
...
Finally I see this error:
2014-02-11 17:11:27,180 ERROR [org.jboss.msc.service.fail] MSC000001: Failed to start service jboss.persistenceunit."inspect.ear/introspe
ct-ejb.jar#Client-EDD": org.jboss.msc.service.StartException in service jboss.persistenceunit."inspect.ear/inspect-ejb.jar#Client-ED
D": java.lang.IllegalArgumentException: interface org.hibernate.annotations.Columns is not visible from class loader
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.IllegalArgumentException: interface org.hibernate.annotations.Columns is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:487)
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:420)
at org.hibernate.annotations.common.annotationfactory.AnnotationFactory.create(AnnotationFactory.java:46)
at org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader.buildColumns(JPAOverriddenAnnotationReader.java:1402)
at org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader.getBasic(JPAOverriddenAnnotationReader.java:1189)
at org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader.initAnnotations(JPAOverriddenAnnotationReader.java:393)
at org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader.isAnnotationPresent(JPAOverriddenAnnotationReader.java:313
)
at org.hibernate.annotations.common.reflection.java.JavaXAnnotatedElement.isAnnotationPresent(JavaXAnnotatedElement.java:60)
at org.hibernate.annotations.common.reflection.java.JavaXMember.isAnnotationPresent(JavaXMember.java:43)
at org.hibernate.cfg.PropertyContainer.mustBeSkipped(PropertyContainer.java:283)
at org.hibernate.cfg.PropertyContainer.initProperties(PropertyContainer.java:201)
at org.hibernate.cfg.PropertyContainer.<init>(PropertyContainer.java:95)
at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:231)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:664)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3456)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3410)
To me it seems like the default JBoss hibernate and JPA always gets loaded, even though we included the exclusions declaration in our deployment descriptor. That causes class loader to ignore the Hibernate 3.6 module we defined.
Please help as I do not know what I have missed. Many thanks in advance!!
Regards,
Matthew