如何配置JBoss EAP 7.0 XA-Datasources?启动报错排查
Let’s break down your two key errors and walk through actionable fixes to get your XA datasources working:
1. Fixing ORA-12514: TNS Listener Doesn’t Recognize the Requested Service
This error almost always boils down to a mismatch between your connection string’s service identifier and what Oracle’s listener actually exposes—even if you think your connection string is correct. Here’s what to check:
Verify the Oracle service name (not SID)
Many developers mix up SID and service names. Run these commands on your Oracle server to confirm the correct service name:- In the Oracle command line:
SELECT value FROM v$parameter WHERE name='service_names'; - Check the listener status:
lsnrctl status(look under "Services Summary" for the valid service names)
Ensure your XA datasource URL uses this exact service name. For example:
<xa-datasource-property name="URL"> jdbc:oracle:thin:@//your-oracle-host:1521/ORCLPDB1 <!-- ORCLPDB1 is the service name here --> </xa-datasource-property>Avoid using SID format (
:@host:port:SID) unless you explicitly need it—XA connections often work better with service names.- In the Oracle command line:
Confirm network reachability
Even if your connection string is right, a firewall might block port 1521 between JBoss and Oracle, or the Oracle listener might only be listening onlocalhost(not the external IP JBoss uses). Test connectivity withtelnet your-oracle-host 1521from the JBoss server to rule this out.
2. Resolving IJ031084: Unable to Create Connection During Crash Recovery
This error ties to JBoss’s XA transaction recovery process. The most common fixes are:
Grant necessary XA permissions to your database user
Oracle requires specific privileges for users handling XA transactions to query pending transactions during recovery. Run these SQL commands as a privileged user:GRANT SELECT ON sys.dba_pending_transactions TO your_db_username; GRANT SELECT ON sys.pending_trans$ TO your_db_username; GRANT SELECT ON sys.dba_2pc_pending TO your_db_username; GRANT EXECUTE ON sys.dbms_xa TO your_db_username;Validate JBoss transaction recovery configuration
In yourstandalone.xml, check the transactions subsystem to ensure recovery is enabled properly:<subsystem xmlns="urn:jboss:domain:transactions:4.0"> <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/> <coordinator-environment default-timeout="300"/> </subsystem>Also, make sure your XA datasource’s recovery settings (if configured) use a user with the permissions above—avoid using a restricted user for recovery.
Additional Troubleshooting Steps
- Test a non-XA datasource first
Set up a basic non-XA datasource with the same connection details. If it fails, you know the issue is with core connectivity (not XA-specific). If it works, focus back on XA permissions and configuration. - Enable debug logging
Boost logging for JBoss’s JCA and Oracle JDBC modules to get granular error details. Add this to yourstandalone.xmllogging subsystem:
The debug logs will show exactly where the connection or recovery process is failing.<logger category="org.jboss.jca"> <level name="DEBUG"/> </logger> <logger category="oracle.jdbc"> <level name="DEBUG"/> </logger>
内容的提问来源于stack exchange,提问作者annie

