3 Replies Latest reply on Mar 23, 2011 1:54 PM by jaikiran pai

    XaDatasource alway fail in JBoss6.0 m2

    Jimmy Shine Newbie

      I want bind a jndi xadatasource.

       

      I had add oralce-xa-datasource

       

      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
          <xa-datasource>
              <jndi-name>OracleDS</jndi-name>
              <track-connection-by-tx>true</track-connection-by-tx>
              <isSameRM-override-value>false</isSameRM-override-value>
              <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
              <xa-datasource-property name="URL">
                  jdbc:oracle:thin:@//127.0.0.1:1521/VAALHAAI
              </xa-datasource-property>
              <xa-datasource-property name="User">vaalhaai</xa-datasource-property>
              <xa-datasource-property name="Password">password</xa-datasource-property>
              <exception-sorter-class-name>
                  org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
              </exception-sorter-class-name>
              <no-tx-separate-pools/>
          </xa-datasource>
                         
          <mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter"
                 name="jboss.jca:service=OracleXAExceptionFormatter">
              <depends optional-attribute-name="TransactionManagerService">
                  jboss:service=TransactionManager
              </depends>
          </mbean>
      </datasources>

       

      and the JPA configuration:

       

      <?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="Vaalhaai" transaction-type="JTA">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <jta-data-source>java:/OracleDS</jta-data-source>
              <properties>
                  <property name="hibernate.archive.autodetection" value="class,hbm" />
                  <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />

       

                  <property name="show_sql" value="true" />
                  <property name="format_sql" value="true" />
              </properties>
          </persistence-unit>
      </persistence>

       

      when i start the application,it always had the error:

       

      11:24:49,500 WARN  [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.lang.ClassCastException: oracle.jdbc.xa.client.OracleXADataSource cannot be cast to javax.sql.XADataSource)
          at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:465)
          at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:409)
          at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:643)
          at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:267)
          at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:659)
          at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:404)
          at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:381)
          at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:497)
          at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:942)
          at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
          at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:71)
          at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:114)
          at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
          at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
          at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:974)
          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:850)
          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
          at org.jboss.jpa.builder.DefaultCEMFBuilder.build(DefaultCEMFBuilder.java:47)
          at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:316)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
          at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:151)
          at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:257)
          at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:125)
          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:72)
          at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:202)
          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
          at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
          at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
          at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:378)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2029)
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1050)
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1289)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1213)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1107)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:873)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:620)
          at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:180)
          at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:58)
          at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
          at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)
          at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1660)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1378)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1399)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1319)
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:378)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2029)
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1050)
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1289)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1213)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1107)
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:918)
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:633)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:898)
          at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:677)
          at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
          at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
          at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
          at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403)
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:378)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2029)
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1050)
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1289)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1213)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1107)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:873)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:620)
          at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308)
          at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:259)
          at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:100)
          at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:860)
          at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:441)
          at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.ClassCastException: oracle.jdbc.xa.client.OracleXADataSource cannot be cast to javax.sql.XADataSource
          at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXADataSource(XAManagedConnectionFactory.java:545)
          at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:449)
          ... 81 more

       

      11:24:49,515 WARN  [SettingsFactory] Could not obtain connection to query metadata: org.jboss.util.NestedSQLException: Unable to get managed connection for OracleDS; - nested throwable: (javax.resource.ResourceException: Unable to get managed connection for OracleDS)
          at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
          at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:71)
          at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:114)
          at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
          at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2159)
          at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1383)
          at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:974)
          at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:850)
          at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
          at org.jboss.jpa.builder.DefaultCEMFBuilder.build(DefaultCEMFBuilder.java:47)
          at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:316)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
          at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:151)
          at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:257)
          at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:125)
          at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:72)
          at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:202)
          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
          at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
          at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
          at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
          at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:378)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2029)
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1050)
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1289)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1213)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1107)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:873)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:620)
          at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:180)
          at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:58)
          at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
          at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)
          at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1660)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1378)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1399)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1319)
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:378)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2029)
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1050)
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1289)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1213)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1107)
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:918)
          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:633)
          at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:898)
          at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:677)
          at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
          at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
          at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
          at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403)
          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:378)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2029)
          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1050)
          at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1289)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1213)
          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1107)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:873)
          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:620)
          at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308)
          at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:259)
          at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:100)
          at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:860)
          at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:441)
          at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.resource.ResourceException: Unable to get managed connection for OracleDS
          at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:442)
          at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:381)
          at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:497)
          at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:942)
          at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
          ... 72 more
      Caused by: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.lang.ClassCastException: oracle.jdbc.xa.client.OracleXADataSource cannot be cast to javax.sql.XADataSource)
          at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:465)
          at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:409)
          at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:643)
          at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:267)
          at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:659)
          at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:404)
          ... 76 more
      Caused by: java.lang.ClassCastException: oracle.jdbc.xa.client.OracleXADataSource cannot be cast to javax.sql.XADataSource
          at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXADataSource(XAManagedConnectionFactory.java:545)
          at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:449)
          ... 81 more

       

      Any one help me!

      Thanks a lot!