random exception

hello,

I am trying to update the xml document in tamino using java API for tamino.

This is my source code:

import com.softwareag.tamino.db.API.accessor.;
import com.softwareag.tamino.db.API.common.
;
import com.softwareag.tamino.db.API.connection.;
import com.softwareag.tamino.db.API.objectModel.
;
import com.softwareag.tamino.db.API.objectModel.dom.;
import com.softwareag.tamino.db.API.response.
;
import java.io.;
import org.w3c.dom.
;
public class taminoUpdate
{

public static void main(String a)
{
try {
TLocalTransaction localTransaction = null;
TXMLObjectAccessor xmlObjectAccessor= null;
TConnection connection= null;
TQuery query=null;

connection = TConnectionFactory.getInstance().newConnection( “http://localhost/tamino/HdoxGlobal”);
xmlObjectAccessor = connection.newXMLObjectAccessor(TAccessLocation.newInstance(“HdoxGlobal”),TDOMObjectModel.getInstance() );
localTransaction = connection.useLocalTransactionMode();
query = TQuery.newInstance( “hdox[@ino:id="4"]” );
System.out.println( “Strart!” );
TResponse re = xmlObjectAccessor.query( query );
TXMLObject xmlObject = re.getFirstXMLObject();
System.out.println(xmlObject.getDocument());
Document element = (Document)xmlObject.getDocument();
Node name = element.getElementsByTagName(“patientId”).item(0);
name.getChildNodes().item(0).setNodeValue(“0”);
System.out.println( “Strar111t!” );
re = xmlObjectAccessor.update( xmlObject );
localTransaction.commit();
connection.useAutoCommitMode();
localTransaction = null;
xmlObjectAccessor= null;
connection= null;
query=null;

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


}
}

What is my problem sometimes it is getting updated but sometimes it is giving the following exception . Please tell me the reason if anybody knows.


Nested Exception (com.softwareag.tamino.db.API.accessor.TAccessorException) stac
ktrace:

Nested Exception (com.softwareag.tamino.db.API.invocation.TInvocationException)
stacktrace:

Nested Exception (com.softwareag.tamino.db.API.connection.TTransactionModeUpdate
Exception) stacktrace:

com.softwareag.tamino.db.API.connection.TTransactionModeUpdateException
Transaction mode cannot be updated. No appropiate transaction state obtained fro
m Tamino!Local Transaction Mode.
Session State sessionId= sessionKey=
at com.softwareag.tamino.db.API.connection.TTransactionMode.update(TTran
sactionMode.java:75)
at com.softwareag.tamino.db.API.connection.TTransactionModeCoordinatorIm
pl.updateModeFrom(TTransactionModeCoordinatorImpl.java:274)
at com.softwareag.tamino.db.API.invocation.TAbstractInvocation.doTemplat
eInvoke(TAbstractInvocation.java:285)
at com.softwareag.tamino.db.API.invocation.TAbstractInvocation.invoke(TA
bstractInvocation.java:156)
at com.softwareag.tamino.db.API.invocation.TAbstractInvocation.invoke(TA
bstractInvocation.java:135)
at com.softwareag.tamino.db.API.accessor.TGenericAccessorImpl.execute(TG
enericAccessorImpl.java:53)
at com.softwareag.tamino.db.API.accessor.TGenericAccessorImpl.execute(TG
enericAccessorImpl.java:78)
at com.softwareag.tamino.db.API.connection.TTransactionModeCoordinatorIm
pl.useLocalTransactionMode(TTransactionModeCoordinatorImpl.java:109)
at com.softwareag.tamino.db.API.connection.TConnectionImpl.useLocalTrans
actionMode(TConnectionImpl.java:206)
at taminoUpdate.main(taminoUpdate.java:23)


Thank you
Dhiraja

This problem puzzles us. Which API version are you using?
You should try the newest version of the API, which is available for download since last week. It will give more information in the TException object, which might help us to find the cause for the problem.
Also instead of catching Exception, please catch TException and print ee.getXMLMessage(), e.g.:

… catch(TException ee){
System.out.println(ee.getXMLMessage());
ee.printStackTrace);
}

This will include every information the API knows.
Beware that you might need to change your classpath slightly with the newset API version.