-
1. Re: userTransaction rollback or commit not working
kconner Aug 22, 2006 12:47 PM (in response to oviwarrior)Can you please expand on the description of your application? If you are using JBossTS then this should work.
-
2. Re: userTransaction rollback or commit not working
oviwarrior Aug 24, 2006 4:16 AM (in response to oviwarrior)Hi Kevin,
I have put my code in a servlet method.
1) I'm using oracle 9i
2) in jboss-service.xml i have put the XidFactory pad to true.
3) in oracle-xml I have decalred 2 datasources. This xml contains:
<xa-datasource>
<jndi-name>XAOracleDS_PARLAMEN</jndi-name>
<use-java-context>false</use-java-context>
<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:@jedi:1521:PARLAMEN</xa-datasource-property>
<xa-datasource-property name="User">ovidio</xa-datasource-property>
<xa-datasource-property name="Password">smart</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
</xa-datasource>
<xa-datasource>
<jndi-name>XAOracleDS_OVIDB</jndi-name>
<use-java-context>false</use-java-context>
<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:@jedi:1521:OVIDB</xa-datasource-property>
<xa-datasource-property name="User">ovidio</xa-datasource-property>
<xa-datasource-property name="Password">smart</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
</xa-datasource>
<!--
<depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager
-->
4) my application code is
//Distributed TX
public void testInsertWithTxXA( String dsS_1,
String dsS_2,
Properties props,
String toInsert,
boolean musthrow)
{
Connection conn_1 = null;
Connection conn_2 = null;
PreparedStatement ps = null;
ResultSet rs = null;
UserTransaction ut = null;
try
{
Context ctx = new InitialContext(props);
DataSource ds_1 = (DataSource) ctx.lookup(dsS_1);
DataSource ds_2 = (DataSource) ctx.lookup(dsS_2);
// Object o = ctx.lookup("java:/TransactionManager");
ut = (UserTransaction)ctx.lookup("UserTransaction");
ut.begin();
checkUserTransaction(ut);
conn_1 = ds_1.getConnection();
conn_2 = ds_2.getConnection();
insert_XA(conn_1, conn_2, INSERT_XA, toInsert, musthrow);
ut.commit();
}
catch(Throwable t)
{
if(ut != null)
{
try
{
ut.rollback();
}
catch(Throwable tu)
{
throw new RuntimeException(tu);
}
}
throw new RuntimeException(t);
}
finally
{
close(conn_1, conn_2, ps, rs);
}
}
5) when i arrive to line ---- conn_1 = ds_1.getConnection();
I have the following exception:
org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=jedi/17, BranchQual=, localId=17]); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=jedi/17, BranchQual=, localId=17]))
6) I can't use JBossTS because the company doen't aloud it.
If you could help me in this one it woud be great.
thanks in advance
ovidio -
3. Re: userTransaction rollback or commit not working
kconner Sep 1, 2006 5:45 AM (in response to oviwarrior)Hiya Ovidio.
Apologies for the delay in responding.
The enlistment of the resource has failed, your log may contain further details. If there is nothing in the log then please enable the TRACE logging for org.jboss.tm.TransactionImpl.
Kev -
4. Re: userTransaction rollback or commit not working
subhashree.mishra Sep 8, 2006 11:07 PM (in response to oviwarrior)Wat is the advantase os using rollback and commit in jdbc connection
-
5. Re: userTransaction rollback or commit not working
vakuthota Sep 14, 2006 2:32 PM (in response to oviwarrior)"oviwarrior" wrote:
Hi Kevin,
I have put my code in a servlet method.
1) I'm using oracle 9i
2) in jboss-service.xml i have put the XidFactory pad to true.
3) in oracle-xml I have decalred 2 datasources. This xml contains:
<datasources>
<xa-datasource>
<jndi-name>XAOracleDS_PARLAMEN</jndi-name>
<use-java-context>false</use-java-context>
<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:@jedi:1521:PARLAMEN</xa-datasource-property>
<xa-datasource-property name="User">ovidio</xa-datasource-property>
<xa-datasource-property name="Password">smart</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
</xa-datasource>
<xa-datasource>
<jndi-name>XAOracleDS_OVIDB</jndi-name>
<use-java-context>false</use-java-context>
<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:@jedi:1521:OVIDB</xa-datasource-property>
<xa-datasource-property name="User">ovidio</xa-datasource-property>
<xa-datasource-property name="Password">smart</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
</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>
4) my application code is
//Distributed TX
public void testInsertWithTxXA( String dsS_1,
String dsS_2,
Properties props,
String toInsert,
boolean musthrow)
{
Connection conn_1 = null;
Connection conn_2 = null;
PreparedStatement ps = null;
ResultSet rs = null;
UserTransaction ut = null;
try
{
Context ctx = new InitialContext(props);
DataSource ds_1 = (DataSource) ctx.lookup(dsS_1);
DataSource ds_2 = (DataSource) ctx.lookup(dsS_2);
// Object o = ctx.lookup("java:/TransactionManager");
ut = (UserTransaction)ctx.lookup("UserTransaction");
ut.begin();
checkUserTransaction(ut);
conn_1 = ds_1.getConnection();
conn_2 = ds_2.getConnection();
insert_XA(conn_1, conn_2, INSERT_XA, toInsert, musthrow);
ut.commit();
}
catch(Throwable t)
{
if(ut != null)
{
try
{
ut.rollback();
}
catch(Throwable tu)
{
throw new RuntimeException(tu);
}
}
throw new RuntimeException(t);
}
finally
{
close(conn_1, conn_2, ps, rs);
}
}
5) when i arrive to line ---- conn_1 = ds_1.getConnection();
I have the following exception:
org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=jedi/17, BranchQual=, localId=17]); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=jedi/17, BranchQual=, localId=17]))
6) I can't use JBossTS because the company doen't aloud it.
If you could help me in this one it woud be great.
thanks in advance
ovidio
Hi Ovidio,
I am also looking for the same requirement to have distributed transaction with 2 different datasources and JMS topic......
but facing the similar problem what you got "enlistResource failed", when i am trying to get the connection from datasource...
i.e.,
17:52:34,405 INFO [TxConnectionManager] Could not enlist in transaction on entering meta-aware object!
javax.transaction.SystemException: enlistResource failed
----
----
17:52:34,405 WARN [TransactionImpl] xa error: -3 (A resource manager error has occured in the transaction branch.); oracle error: 65535; oracle sql error: -1;
oracle.jdbc.xa.OracleXAException
at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1157)
at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:295)
I configured oracle-xa-ds.xml, set pad=true in jboss-service.xml.
I appreciate if you can share if you have solved this. Please reply with full details.
Pls suggest what all i need to configure to make the oracle database XA compliant ??
thanks in advance...
Venu -
6. Re: userTransaction rollback or commit not working
kconner Sep 15, 2006 5:01 AM (in response to oviwarrior)17:52:34,405 WARN [TransactionImpl] xa error: -3 (A resource manager error has occured in the transaction branch.); oracle error: 65535; oracle sql error: -1;
oracle.jdbc.xa.OracleXAException
at oracle.jdbc.xa.OracleXAResource.checkError(OracleXAResource.java:1157)
at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:295)
This message appears to have come from the Oracle database. Can you check the Oracle logs and see whether they contain more information?
Kev -
7. Re: userTransaction rollback or commit not working
vakuthota Sep 15, 2006 11:44 AM (in response to oviwarrior)The problem is because Oracle database is not XA compliant, thus throwing the following exception
OracleXAException: XAER_RMERR (Internal XA Error).
Reason for problem:
The error is that the transaction manager was unable to convert the transaction to an XA transaction. Specifically, Oracle returned an error XAER_RMERR, error code number 65535. ORA-65535 is not a valid error code and XAER_RMERR essentially means that something went wrong with XA. What this indicates is that your Oracle database is not configured to support XA transactions. Therefore, when the WebSphere Application Server transaction manager instructs the Oracle transaction manager to participate in this XA transaction, Oracle cannot comply and throws this exception
Solution :
The solution is to run two scripts that are included in the Oracle install. This will likely need to be performed by your Oracle DBA, since you must be logged into Oracle as SYSOPER or SYSDBA in order to have the necessary permissions for these scripts to work. The scripts are:
directory: <ORACLE_HOME>\javavm\install
file:initxa.sql
file: initjvm.sql
The initxa.sql script configures the database for XA. Once it runs successfully, your database is configured for XA. The script may run successfully the first time you try. Unfortunately, it probably will not run successfully because some of the database's memory spaces are too small. To fix this, run the initjvm.sql script. It will probably fail too, but in doing so it will indicate which parameters need to be adjusted. The parameters are stored in this file:
directory: <ORACLE_HOME>\database
file: init<DATABASE_SID>.ora
This table shows two parameters that typically need to be increased. Your particular database configuration may require adjusting different parameters.
Oracle Initialization Values
Parameter Name Minimum Value
java_pool_size 12000000
shared_pool_size 24000000
Once initjvm.sql runs successfully, then initxa.sql should run successfully. The Oracle database will need to be restarted for the changes to take effect.
And for XA_Recovery, following grants must be given by SYSDBA :
grant select on DBA_PENDING_TRANSACTIONS to PUBLIC
You can see more details information from the following link :
http://www-128.ibm.com/developerworks/websphere/library/techarticles/0407_woolf/0407_woolf.html?ca=dnp-327Scroll