Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Problem in Session Bean TransactionRolledbackException

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Frnds,
I am working on IBM VAJ 3.5.3 and ihd write entity beans.
I am having a session bean (No 1) (for inserting record in DB as three tables r there icn not use directly entity ejb) and from that session bean i am calling another session bean (No 2) which is getting the max value from database for inserting the record. I want this bean for entire application as i wll be generating unique id for each n every table, for that ihd created session bean.
And after getting the max value i am inserting this max value and other data gathered from user in database through two different entity beans.
So now when i am doing this i am getting javax.transaction.TransactionRolledbackException.
But if i am calling only (No 2)bean that for getting max value from database and not intserting record throug entity thn it is working fine , the another bean(No 2 ) is giving the desired result.
And if i am calling only insert operation and not bean (No 2) than also it is working fine.
The problem is that I am doing database operation in My (No 2)bean , doing connection and one select query. if i am commenting it out that whole the thing is working correctly.
The whole error is as follows , if anybody can help me , pls send reply :
Exception is:
javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 0 No; nested exception is:
org.omg.CORBA.TRANSACTION_ROLLEDBACK: com.ibm.websphere.csi.CSITransactionRolledbackException:
java.lang.Throwable(java.lang.String)
java.lang.Exception(java.lang.String)
java.io.IOException(java.lang.String)
java.rmi.RemoteException(java.lang.String)
com.ibm.websphere.csi.CSIException(java.lang.String)
com.ibm.websphere.csi.CSITransactionRolledbackException(java.lang.String)
void com.ibm.ejs.csi.TranStrategy.commit()
void com.ibm.ejs.csi.TranStrategy.postInvoke(com.ibm.websphere.csi.EJBKey, com.ibm.ejs.csi.TxCookieImpl)
void com.ibm.ejs.csi.TransactionControlImpl.postInvoke(com.ibm.websphere.csi.EJBKey, com.ibm.websphere.csi.TxCookie, com.ibm.websphere.csi.ExceptionType)
void com.ibm.ejs.container.EJSContainer.postInvoke(com.ibm.ejs.container.EJSWrapper, int, com.ibm.ejs.container.EJSDeployedSupport)
void com.next.analysis.ejbs.EJSRemoteInsertMTFigureItem.insert()
org.omg.CORBA.portable.OutputStream com.next.analysis.ejbs._EJSRemoteInsertMTFigureItem_Tie._invoke(java.lang.String, org.omg.CORBA.portable.InputStream, org.omg.CORBA.portable.ResponseHandler)
com.ibm.rmi.ServerResponse com.ibm.CORBA.iiop.ExtendedServerDelegate.dispatch(com.ibm.rmi.ServerRequest)
com.ibm.rmi.ServerResponse com.ibm.CORBA.iiop.ORB.process(com.ibm.rmi.ServerRequest)
void com.ibm.CORBA.iiop.WorkerThread.run()
void com.ibm.ejs.oa.pool.ThreadPool$PooledThread.run()
minor code: 0 completed: No
Ketan Khimani
Nextgen InfoNET Pvt. Ltd.
------------------
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the code that is causing the problem? (The stuff you are commenting out).
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
Ketan Khimani
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code . I am inserting comment as it is as im not getting the error.
Thanks .
Code :
public String getMaxPrimaryValue(String TableName, String preffix)
throws com.next.analysis.exceptions.TableNotFoundException {
try {
column = "";
table = TableName.toUpperCase();
/*
AnalysisContext context = new AnalysisContext();
java.sql.Connection conKet = context.getConnection();

ResultSet rsKet = conKet.getMetaData().getPrimaryKeys("", "EJSADMIN", table);
if (rsKet.next()) {
System.out.println(" Table Name : " + rsKet.getString("TABLE_NAME"));
System.out.println(" PK Name : " + rsKet.getString("PK_NAME"));
System.out.println(" Column Name : " + rsKet.getString("COLUMN_NAME"));
System.out.println(" Schema Name : " + rsKet.getString("TABLE_SCHEM"));
table = rsKet.getString("TABLE_NAME");
column = rsKet.getString("COLUMN_NAME");
} else {
System.out.println("There is no record in Result Set.");
}
ResultSet rsKet = null;
sql = "SELECT " + column + " FROM " + table;

psKet = conKet.prepareStatement(sql);
rsKet = psKet.executeQuery();
int idOne = 0;
int idTwo = 0;
int last = 0;
while (rsKet.next() != false) {
preffix = rsKet.getString(1).substring(0, 1);
idOne = Integer.parseInt(rsKet.getString(1).substring(1));
System.out.println("ID : " + idOne);
if (rsKet.next()) {
idTwo = Integer.parseInt(rsKet.getString(1).substring(1));
} else {
last = idOne;
}
if (idOne > idTwo) {
last = idOne;
} else {
last = idTwo;
}
idOne = last;
idTwo = last;
} //end while
last = last + 1;
System.out.println("Max Value " + last);
preffix = preffix + last;
if (rsKet != null)
rsKet.close();
if (psKet != null)
psKet.close();
if (conKet != null)
conKet.close();

return preffix;
*/
return "F10001";
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
return null;
}
Here is AnalysisContext Class ::::
public class AnalysisContext {
private java.sql.Connection conn = null;
private javax.naming.Context ctx = null;
public AnalysisContext() {
super();
}
public java.sql.Connection getConnection() throws java.sql.SQLException,java.lang.Exception {
try {
if(conn == null){
javax.naming.Context jndiContext = getInitialContext();
DataSource ds = (DataSource) jndiContext.lookup("jdbc/ORANTNEW");
System.out.println("Got the Connection");
this.conn = ds.getConnection("ejsadmin","ejsadmin");
}
return conn;
} catch(Exception ne) {
System.out.println("Exception in getConnection");
throw new javax.ejb.EJBException("Exception in getHome" +ne.getMessage());
}
}

public Object getHome(String name, Class type) throws java.lang.Exception {
try {

System.out.println("Me in getHome");
javax.naming.Context jndiContext = getInitialContext();
System.out.println("got jndiContext" + jndiContext);
System.out.println("Going to call lookup");
Object ref = jndiContext.lookup(name);

return javax.rmi.PortableRemoteObject.narrow(ref,type);
}
catch (Exception ne) {
ne.printStackTrace();
throw new javax.ejb.EJBException("Exception in getHome" +ne.getMessage());
}

}
public javax.naming.Context getInitialContext() throws javax.naming.NamingException {
System.out.println("Me in Context.getInitialContext");
if(this.ctx==null){
java.util.Hashtable env = new java.util.Hashtable();
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
env.put(javax.naming.Context.PROVIDER_URL,"IIOP://localhost:900/";);
this.ctx = new javax.naming.InitialContext(env);
System.out.println("Context "+ctx);
}
return ctx;
}
}
In the above code I m confirm tht im getting error somewhere connection only. As i hd previously mentioned without calling the entity i am getting the max value perfactly.And if I am calling entity , and when container calls ejbstore() after that only it gets Rolledback exception.The problem is i think somewher in connection or somewhere that. But if i m calling only that connection tht is working. wht is the problem???
Thanks
Ketan Khimani
NextGen InfoNET Pvt. Ltd.
[This message has been edited by Ketan Khimani (edited October 23, 2001).]
[This message has been edited by Ketan Khimani (edited October 24, 2001).]
 
Ketan Khimani
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I got the solution .
In My both session beans "Transaction Attribute" was set to
"TX_REQUIRED" , so because of that container was starting Transaction . So ihd change the "Transaction Attribute" of No. 2 session bean which I was calling from No.1 session bean to "TX_REQUIRES_NEW" , and everything ws working fine.
I dont know exact meaning of TX_REQUIRED and TX_REQUIRES_NEW , if anybody can tell me the url of any document on Transaction on vadd than thant would be helpful, otherwise ihd to read Haefel s book s chapter on TRANSACTION.
Thanks.
Ketan Khimani
NextGen InfoNET Pvt. Ltd.

 
I've never won anything before. Not even a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic