Issue with XAResource class load in Jboss AS 7.1

2019-08-05 06:44发布

I'm having a very annoying issue with a class being loaded two times by de ojdbc6 driver in Jboss AS 7.1. I have researched all through google and haven't found any answer.

This is the problem: I have two ears being deployed in JBoss, one of them has in it's jboss-deployment-structure the dependency with the oracle module in JBoss, which depends on javax.api and javax.transaction.api. The other ear executes some liquibase change control on it's startup by using an ant task, this ant task has as classpath the jars needed to run liquibase (the oracle driver is the same one in the JBoss modules). In the standalone-full.xml I have some xa:datasources defined needed by the first ear.

Now, the problem is that when the server starts and after the liquibase change controls, executes correctly the connections to the xa:datasources cannot be created because of this error:

11:56:00,029 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.PoolBySubject] (MSC service thread 1-6) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: Could not create connection
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:447) [ironjacamar-jdbc-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:385) [ironjacamar-jdbc-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:761)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:343)
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:397)
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:365)
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:329)
at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:368)
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:464)
at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:129) [ironjacamar-jdbc-1.0.9.Final.jar:1.0.9.Final]
at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:141) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:253) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:119) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at saes.util.HibernateDB.init(HibernateDB.java:1047) [session.jar:]
at saes.admin.init.servlet.InitServlet.init(InitServlet.java:105) [session.jar:]
at saes.admin.init.servlet.REISInitServlet.init(REISInitServlet.java:57) [session.jar:]
at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "oracle.jdbc.xa.client.OracleXAConnection.getXAResource()Ljavax/transaction/xa/XAResource;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, oracle/jdbc/xa/client/OracleXAConnection, and the class loader (instance of <bootloader>) for interface javax/sql/XAConnection have different Class objects for the type ransaction/xa/XAResource; used in the signature
at oracle.jdbc.xa.client.OracleXADataSource.getPooledConnection(OracleXADataSource.java:469)
at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:156)
at oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:130)
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:430) [ironjacamar-jdbc-1.0.9.Final.jar:1.0.9.Final]
... 34 more

After some debugging I have concluded that when the liquibase executes the jboss loads the oracle driver a first time and uses (loads) the XAResource from the rt.jar of the jre but after this when the other ear tries to create connections to the datasources it uses the oracle in jboss modules that loads the XAResource class from the javax.transaction.api module so the server throws the exception.

Is there any way to use another class loader for the liquibase execution or tell it that the XAResource class must not be loaded from the rt.jar? Have anybody encounter this issue before or have any idea how to solve it?

Thank your for any help you can give

0条回答
登录 后发表回答