使用 jBoss + Oracle 使用 oracle-xa-ds.xml 进行分布式事务处理
我们会进行 配置 2到多个数据库 在启动jBoss时会报:
org.jboss.deployment.DeploymentException: Trying to install an already registered mbean: jboss.jca:service=OracleXAExceptionFormatter
jBoss内容:
--- Incompletely deployed packages ---
org.jboss.deployment.DeploymentInfo@9dc2668e { url=file:/G:/jboss-4.2.3.GA/server/CE/deploy/Objst1DSXA-ds.xml }
deployer: org.jboss.deployment.XSLSubDeployer@3b100c
status: Deployment FAILED reason: Trying to install an already registered mbean: jboss.jca:service=OracleXAExceptionFormatter
state: FAILED
watch: file:/G:/jboss-4.2.3.GA/server/CE/deploy/Objst1DSXA-ds.xml
altDD: null
lastDeployed: 1259016129625
lastModified: 1259016129609
mbeans:
原因:
When creating datasources using the P8 Configuration Manager and executing the 'Configure JDBC Data Sources' task, two data source files (one XA and one non-XA) are placed into the deployed JBoss server. The XA data source files will contain the following lines:
-
<mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter"
name="jboss.jca:service=OracleXAExceptionFormatter">
<depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
</mbean>
Only one XA data source file can contain the above entry. The problem occurs when more than one XA data source file contains this entry.
All XA datasource files created by the P8 Configuration Manager utility will have the "mbean code" entry in the file. This entry will need to be removed from all XA datasource files that were created by the P8 Configuration Manager utility after the GCD XA datasource file was created. It should remain in the GCD XA data source file because that is the first XA datasource file to be created and it should be in one of the files.
!!!!!!!!!!!!!!!!!!!
解决方案:
将你所配置的数据库文件 如:oracle1-xa-ds.xml、oracle2-xa-ds.xml、oracle3-xa-ds.xml .......
jBoss只能正常加载一个 所以之后的 *.xml都会报以上错误
我们只要将 第2-n个*.xml 的内容删除:
<mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter"
name="jboss.jca:service=OracleXAExceptionFormatter">
<depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
</mbean>
再重启jBoss