Hi all, here's the Exception:
org.exolab.castor.jdo.ObjectNotPersistentException: The object of type
x.y.z.ServiceInfo is not persistent -- it was not queried or created within this
transaction
at
org.exolab.castor.persist.TransactionContext.writeLock(TransactionContext.java:1177)
at org.exolab.castor.jdo.engine.DatabaseImpl.lock(DatabaseImpl.java:423)
at jdo.post.ActionLib.setServiceInfo(ActionLib.java:2940) <<<< my code
It happens intermittently and it is very hard to get repro steps. Only multiple users
with multiple windows can re-create it. I have had no luck. After it occurs, there is
a rush of LockNotGrantedExceptions.The ActionLib class is a singleton that has a
getInstance() method. I'm wondering if this might be why I get the
LockNotGrantedExceptions after this one.
/* Here's the code: */
public DocumentFragment setServiceInfo(String customerServiceId, String svcInfoId,
String svcInfoValue, String remoteUserName ) {
DocumentFragment frag = document.createDocumentFragment();
if (remoteUserName != null)
this.m_remoteUserName = remoteUserName;
if ( svcInfoId == null ) return frag;
try {
if ( ! persistentDb ) db = loadDatabase();
db.begin();
// Update the Info object.
ServiceInfo si = (ServiceInfo) getObjectByParam( "ServiceInfo", svcInfoId
);
//stamp customer service
if ( customerServiceId != null && customerServiceId.length() > 0) {
CustomerService cs = (CustomerService) getObjectByParam(
"CustomerService", customerServiceId );
if (cs != null) {
cs.setModifiedBy(this.m_remoteUserName);
cs.setModifiedTimestamp(new Date() );
}
}
//upgrade the lock
db.lock(si); //<<<< Exception thrown here. why isn't si in this
transaction ???
si.setValue( svcInfoValue );
db.commit();
}
catch (Exception e) {
if (db != null && db.isActive()) {
try { db.rollback(); }
catch ( TransactionNotInProgressException tnipe ) {
}
}
frag.appendChild(createErrorElement(e));
}
finally {
try {
if ( ! persistentDb ) db.close();
}
catch (Exception close_e) {
}
return frag;
}
}
// ---------- supporting methods -------------------
/** wrapper for getObjectById that parses the integer id from the object param
* uses caller's transaction */
private Object getObjectByParam( String className, Object param )
throws IllegalArgumentException,
QueryException,
PersistenceException {
int id = Integer.parseInt( (String) param );
if ( className.indexOf('.') == -1 ) className = DEFAULT_PACKAGE + "." +
className;
Object obj = this.getObjectById( className, id );
if ( obj == null ) {
String shortName = className.substring( className.lastIndexOf('.') );
throw new IllegalArgumentException( "Invalid "+ shortName +" id: "+ id );
}
return obj;
}
/** uses caller's transaction - does the actual query */
protected Object getObjectById(String className, int id )
throws QueryException, PersistenceException {
Object result = null;
OQLQuery oqlQuery = db.getOQLQuery( "SELECT x FROM "+ className +" x WHERE id
= $1" );
oqlQuery.bind(id);
QueryResults results = oqlQuery.execute();
if( results.hasMore() ) result = results.next();
results.close();
oqlQuery.close();
return result;
}
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev