I'm developping an application which has multiple parallel transactions. Now I have the problem that the same data object may be loaded in more than one transaction at the same time. If one of the transactions changes the object and tries to commit I get an LockNotGrantedException:
org.exolab.castor.jdo.TransactionAbortedException: Nested error:
org.exolab.castor.jdo.LockNotGrantedException: persist.writeTimeoutmyapp.Computer/1/0 by
[EMAIL PROTECTED]
org.exolab.castor.jdo.LockNotGrantedException:
persist.writeTimeoutmyapp.Computer/1/0 by [EMAIL PROTECTED]
at org.exolab.castor.persist.ObjectLock.upgrade(ObjectLock.java:714)
at org.exolab.castor.persist.LockEngine$TypeInfo.upgrade(LockEngine.java:1132)
at org.exolab.castor.persist.LockEngine$TypeInfo.access$600(LockEngine.java:963)
at org.exolab.castor.persist.LockEngine.writeLock(LockEngine.java:805)
at org.exolab.castor.persist.TransactionContext.writeLock(TransactionContext.java:1285)
at org.exolab.castor.persist.ClassMolder.preStore(ClassMolder.java:1541)
at org.exolab.castor.persist.LockEngine.preStore(LockEngine.java:723)
at org.exolab.castor.persist.TransactionContext.prepare(TransactionContext.java:1462)
at org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:528)
at myapp.Test.run(Test.java:89)
at myapp.Test.main(Test.java:53)
Is there an possibility to avoid this exception?
Here is an example code which produces the error. The exception is thrown when I call db2.commit():
JDO jdo = new JDO();
jdo.setConfiguration("database.xml");
jdo.setDatabaseName("test");Database db1 = jdo.getDatabase(); Database db2 = jdo.getDatabase();
db1.begin(); db2.begin();
Computer amd1 = (Computer) db1.load(Computer.class, new Integer(1)); Computer amd2 = (Computer) db2.load(Computer.class, new Integer(1));
amd2.setCpu("AMD" + ((int) (Math.random()*100)));
db2.commit(); db1.commit();
Mapping: <!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.exolab.org/mapping.dtd">
<mapping>
<class name="myapp.Computer" identity="id" access="shared">
<map-to table="COMPUTER" xml="computer" />
<field name="id" type="integer">
<sql name="ID" type="integer" />
</field>
<field name="cpu" type="string">
<sql name="CPU" type="char"/>
</field>
</class>
</mapping>Thanks in advance! Tom
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
