Problem in getting JTA to work with WebSphere 3.5.4
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sanjay_r
Posted On:   Wednesday, January 9, 2002 01:03 PM

I have a problem in getting JTA to work with WebSphere 3.5.4. I am currently testing in the Visual Age for Java test environment (using a JTA enabled driver in WebSphere - basically lookin up WebSPhere's JNDI instead of VAJ's PNS server). The code i am using to test JTA is as follows : public void jtatest() throws java.io.IOException { try { java.util.Properties parms = new java.util.Properties(); parms.setProperty( Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory"); javax.naming.InitialContext ctx = new javax.naming.InitialContext(parms); UserTransaction transaction = (UserTransaction) ctx.lookup("jta/usertransaction");    More>>

I have a problem in getting JTA to work with WebSphere 3.5.4. I am currently testing in the Visual Age for Java test environment (using a JTA enabled driver in WebSphere - basically lookin up WebSPhere's JNDI instead of VAJ's PNS server). The code i am using to test JTA is as follows :



			
public void jtatest() throws java.io.IOException {
try {

java.util.Properties parms = new java.util.Properties();
parms.setProperty(
Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory");

javax.naming.InitialContext ctx = new javax.naming.InitialContext(parms);
UserTransaction transaction = (UserTransaction) ctx.lookup("jta/usertransaction");

transaction.begin();

javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("jdbc/TestDS");
System.out.println(" Datasource retrieved. ");

try {
java.sql.Connection connection = ds.getConnection("username", "password");
System.out.println(" Connection established. ");
Statement statement = connection.createStatement();

statement.executeQuery("select A,B,c from SAMPLE");

} catch (NullPointerException x) {
x.printStackTrace();
}

transaction.commit();

} catch (Exception e) {
e.printStackTrace();
}
}



The datasource i am using (TestDS) is JTA enabled. When i run this code. I get a NullPointerException in the ds.getConnection("username","password")
method. If i take the connection from the Datasource before i start a user Transaction(transaction.begin()) i am able to get the connection but when i try to execute the select query, i get the NullPOinterProblem again. The stack Trae of the problem is as follows :

			

java.lang.NullPointerException
java.lang.Throwable()
java.lang.Exception()
java.lang.RuntimeException()
java.lang.NullPointerException()
boolean
com.ibm.ejs.cm.pool.ConnectO.enlist(org.omg.CosTransactions.Coordinator, int)
boolean
com.ibm.ejs.cm.pool.ConnectO.enlist(org.omg.CosTransactions.Coordinator, int)
boolean
com.ibm.ejs.cm.pool.JTAConnectO.enlist(org.omg.CosTransactions.Coordinator, int)
void com.ibm.ejs.cm.pool.ConnectO.enlist()
void com.ibm.ejs.cm.pool.ConnectO.preInvoke(boolean)
void com.ibm.ejs.cm.proxy.Proxy.__preInvoke(boolean)
java.sql.ResultSet
com.ibm.ejs.cm.proxy.StatementProxy.executeQuery(java.lang.String)
void
com.jta.MyTest.testJTA()


The databse url prefix specified for the Datasouce is jdbc:db2:sample (dont need jdbc:jta:jdbc:sample in WebSphere 3.5.4)

Any suggestions anyone? why is this failing???


thanks a lot..
Sanjay

   <<Less
About | Sitemap | Contact