aspose file tools*
The moose likes Websphere and the fly likes JTA, JDBC, Websphere 5.0.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "JTA, JDBC, Websphere 5.0.2" Watch "JTA, JDBC, Websphere 5.0.2" New topic
Author

JTA, JDBC, Websphere 5.0.2

Sean Sullivan
Ranch Hand

Joined: Sep 09, 2001
Posts: 427
I am using:
- IBM Websphere Application Server 5.0.2
- Oracle9i release 2
- an Oracle JDBC DataSource (XA is enabled)
I am not using EJB's.
When I execute my servlet, I see a javax.transaction.SystemException
-----------
I found this information in SystemOut.log:
-----------
[7/18/03 22:51:28:739 PDT] 11e25926 ConnectionFac I J2CA0122I: Resource reference jdbc/OracleXADataSource could not be located, so default values of the following are used: [Resource-ref settings]

res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)
[Other attributes]
isCMP1_x: false (not CMP1.x)
isJMS: false (not JMS)
[7/18/03 22:51:28:739 PDT] 11e25926 ConnectionFac I J2CA0107I: Component-managed authentication alias not specified for connection factory or datasource OracleXADataSource.
[7/18/03 22:51:37:953 PDT] 11e25926 WSRdbDataSour u Database version is
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
[...]
[7/18/03 22:51:56:730 PDT] 11e25926 XATransaction E J2CA0030E: Method enlist caught javax.transaction.SystemException: Failed to start the transaction association.
at com.ibm.ejs.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:782)
at com.ibm.ejs.jts.jta.JTSXA.enlist(JTSXA.java:998)
at com.ibm.ejs.j2c.XATransactionWrapper.enlist(XATransactionWrapper.java:740)
at com.ibm.ejs.j2c.ConnectionEventListener.interactionPending(ConnectionEventListener.java:743)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processInteractionPendingEvent(WSRdbManagedConnectionImpl.java:1299)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:328)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.java:697)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.java:673)
at foobar.demo.Util.dropFooTable(Util.java:67)
at foobar.demo.Setup.execute(Setup.java:32)
at foobar.demo.DemoServlet.doGet(DemoServlet.java:23)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
[...]

while trying to enlist resources from datasource jdbc/OracleXADataSource with the Transaction Manager for the current transaction, and threw a ResourceException.
[7/18/03 22:51:58:422 PDT] 11e25926 LocalTransact E WLTC0033E: Resource jdbc/OracleXADataSource rolled back in cleanup of unresolved LocalTransactionContainment.
[7/18/03 22:51:58:462 PDT] 11e25926 LocalTransact E WLTC0032E: One or more resources rolled back. An unresolved LocalTransactionContainment had an unresolved action of rollback.
[7/18/03 22:51:58:462 PDT] 11e25926 WebAppTransac E SRVE0183E: LocalTransaction rolled-back due to setRollbackOnly
[7/18/03 22:51:58:492 PDT] 11e25926 WebGroup E SRVE0026E: [Servlet Error]-[LocalTransaction rolled-back due to setRollbackOnly]: com.ibm.ws.LocalTransaction.RolledbackException
at com.ibm.ws.LocalTransaction.LocalTranCoordImpl.cleanup(LocalTranCoordImpl.java:967)
at com.ibm.ws.webcontainer.webapp.WebAppTransactionCollaborator.postInvoke(WebAppTransactionCollaborator.java:208)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:673)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:176)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:201)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[...]
-----------
SystemErr.log contains this information:
-----------
[7/18/03 22:51:58:162 PDT] 11e25926 SystemErr R strMsg = java.sql.SQLException: ORA-00933: SQL command not properly ended
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1894)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:831)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2496)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2840)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:536)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:510)
at foobar.demo.basic.MovieDAOImpl.findMovieById(MovieDAOImpl.java:45)
[...]
Sean Sullivan
Ranch Hand

Joined: Sep 09, 2001
Posts: 427
"Frank Neumann" wrote
> I could imagine that there is no global (container- or user-) transaction
> running when you try to access the Oracle DataSource.
> Because Oracle's XA datasource cannot be used in a local transaction
> environment (this is a bug, it should according the specs), you might want
> to try using a data source based on a pooled connection rather than an XA
> connection for your operation.
My configuration:
1) IBM Websphere Application Server 5.0.2
2) database: Oracle9i release 2
3) Oracle JDBC DataSource (XA is enabled)
4) I am using JTA transactions: UserTransaction
Can anybody explain the meaning of this message:
"Failed to start the transaction association"
This stack trace shows what is happening:
java.sql.SQLException: DSRA9002E: ResourceException with error code null:
javax.resource.ResourceException: enlist: caught Exception
at
com.ibm.ejs.j2c.XATransactionWrapper.enlist(XATransactionWrapper.java:841)
at
com.ibm.ejs.j2c.ConnectionEventListener.interactionPending(ConnectionEventLi
stener.java:743)
at
com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processInteractionPendin
gEvent(WSRdbManagedConnectionImpl.java:1299)
at
com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdb
cConnection.java:328)
at
com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.
java:697)
at
com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.
java:673)
at foobar.movie.MovieUtil.dropMovieTable(MovieUtil.java:68)
at foobar.movie.demo.Setup.execute(Setup.java:33)
at foobar.movie.demo.DemoServlet.doGet(DemoServlet.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServle
tInstance.java:110)
at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecy
cleServlet.java:174)
at
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServ
let.java:313)
at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecyc
leServlet.java:116)
at
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java
:283)
at
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidSer
vletReferenceState.java:42)
at
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletIns
tanceReference.java:40)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(
WebAppRequestDispatcher.java:948)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppReques
tDispatcher.java:530)
at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequest
Dispatcher.java:176)
at
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:79)
at
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker
.java:201)
at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(C
achedInvocation.java:71)
at
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletReq
uestProcessor.java:182)
at
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListene
r.java:334)
at
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.jav
a:56)
at
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:610)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:431)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
-------- chained exception -------
javax.transaction.SystemException: Failed to start the transaction
association.
at
com.ibm.ejs.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:782)
at com.ibm.ejs.jts.jta.JTSXA.enlist(JTSXA.java:998)
at
com.ibm.ejs.j2c.XATransactionWrapper.enlist(XATransactionWrapper.java:740)
at
com.ibm.ejs.j2c.ConnectionEventListener.interactionPending(ConnectionEventLi
stener.java:743)
at
com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processInteractionPendin
gEvent(WSRdbManagedConnectionImpl.java:1299)
at
com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdb
cConnection.java:328)
at
com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.
java:697)
at
com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.createStatement(WSJdbcConnection.
java:673)
at foobar.movie.MovieUtil.dropMovieTable(MovieUtil.java:68)
at foobar.movie.demo.Setup.execute(Setup.java:33)
at foobar.movie.demo.DemoServlet.doGet(DemoServlet.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
Sean Sullivan
Ranch Hand

Joined: Sep 09, 2001
Posts: 427
I resolved this issue.
My application contained this faulty code:
// ...
Connection conn = obtainConnectionFromXADataSource();
conn.setAutoCommit(true);
// ...
String strStmt = "DROP TABLE foobar";
Statement stmt = conn.createStatement();
The root of the problem is that my code was calling "setAutoCommit(true)"
After removing setAutoCommit(true), the exception
("Failed to start the transaction association") disappeared.
There was also another issue that I had to resolve.
If you are using an Oracle XA DataSource, Oracle's JDBC driver
will automatically issue a COMMIT when it sees a "DROP TABLE foobar"
statement.
Oracle's JDBC driver cannot properly execute a
DROP TABLE statement unless you are using a non-XA DataSource.
With the non-XA Oracle DataSource, I can happily execute "DROP TABLE foobar"
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JTA, JDBC, Websphere 5.0.2