-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ok, I've narrowed the problem down in my xml mapping file.  Basically, if I
turn off lazy collection for my map between on server object to multiple
jarfiles, then it works fine in a multi-threaded environment.  I can work
up an example if needed.

On 12-Nov-2001 Ned Wolpert wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Folks-
> 
>   I've been doing more testing lately, and I've got a threading problem
> with
> castor, and I'm not sure on the proper fix.  Consider this code of my test
> example:
> 
> public class DBTest implements Runnable{
> 
>  int number;
>  public DBTest(int i){
>      number=i;  }
> 
>  public void run() {
>    try {
>      Debug.printEnter(this,"Test number: "+number);
>      String dbname = "mediamgmt";            
>      String confFileName="/mediamgmt-castor.xml";
>      JDO jdo = new JDO();
>      jdo.setLogWriter(Logger.getSystemLogger());
>      jdo.setClassLoader( getClass().getClassLoader() );
>      jdo.setConfiguration(getClass().getResource(confFileName).toString());
>      jdo.setDatabaseName(dbname);
>      Database db = jdo.getDatabase();
>      db.begin();
>      int name = 1;
>      OQLQuery oql = db.getOQLQuery("Select s from " +
>             "org.mv5.delivery.model.Server s where s.id = $1");
>      oql.bind(name);
>      QueryResults qr = oql.execute();
>      if (!qr.hasMore()){
>            throw new GeneralException("No such server.2");
>      }        
>      Server s = (Server)qr.next();
>      qr.close();
>      oql.close();
>      db.commit();
>      db.close();
>      Debug.printExit(this,"Test number: "+number);
>    } catch (Exception e){
>      Debug.print(this,e.getMessage(),Debug.ERROR,e);
>    }
>  }
> 
>  public static void main(String[]argv){
>    try {
>      int num = 5;
>      if (argv.length>0){
>          num = Integer.parseInt(argv[0]);
>      }
>      Thread[] testList = new Thread[num];
>      for (int i=0;i<testList.length;i++){
>          testList[i]=new Thread(new DBTest(i));
>      }
>      for (int i=0;i<testList.length;i++){
>          testList[i].start();
>      }
>    } catch (Exception e){
>      e.printStackTrace();
>    }
>  }
> }
> 
> This example queries for a 'server' object, where there is only one.  When
> I
> run it with an argument of 1 (one thread), it works fine. No exceptions. 
> But
> when I run it with an argument of 2 (two threads) it fails with the
> following
> stacktrace. (Sorry, my emailer reformats it)
> 
> java.lang.NullPointerException: Adding null value is not allowed
>         at
> org.exolab.castor.persist.FieldMolder.addValue(FieldMolder.java:268)
>         at
> org.exolab.castor.persist.CollectionProxy$ColProxy.add(ClassMolder.java:2943
> )
>         at
> org.exolab.castor.persist.ClassMolder.revertObject(ClassMolder.java:2452)
>         at
> org.exolab.castor.persist.LockEngine.revertObject(LockEngine.java:861)
>         at
> org.exolab.castor.persist.TransactionContext.rollback(TransactionContext.jav
> a:
> 1604)
>         at
> org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:502)
>         at DBTest.run(DBTest.java:42)
>         at java.lang.Thread.run(Thread.java:484)
> 7492 [Thread-1] ERROR interactive  - [ ERROR ]-[ class DBTest ]-[ at
> DBTest.run(DBTest.java:46) ]-[ Nested error:
> org.exolab.castor.jdo.LockNotGrantedException: persist.deadlock ]
> org.exolab.castor.jdo.LockNotGrantedException: persist.deadlock
>         at
> org.exolab.castor.persist.ObjectLock.detectDeadlock(ObjectLock.java:928)
>         at
> org.exolab.castor.persist.ObjectLock.upgrade(ObjectLock.java:722)
>         at
> org.exolab.castor.persist.LockEngine$TypeInfo.upgrade(LockEngine.java:1151)
>         at
> org.exolab.castor.persist.LockEngine$TypeInfo.access$600(LockEngine.java:964
> )
>         at
> org.exolab.castor.persist.LockEngine.writeLock(LockEngine.java:806)
>         at
> org.exolab.castor.persist.TransactionContext.writeLock(TransactionContext.ja
> va
>:1183)
>         at
> org.exolab.castor.persist.ClassMolder.preStore(ClassMolder.java:1504)
>         at
> org.exolab.castor.persist.LockEngine.preStore(LockEngine.java:724)
>         at
> org.exolab.castor.persist.TransactionContext.prepare(TransactionContext.java
>:1
> 360)
>         at
> org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:499)
>         at DBTest.run(DBTest.java:42)
>         at java.lang.Thread.run(Thread.java:484)
> java.lang.NullPointerException: Adding null value is not allowed
>         at
> org.exolab.castor.persist.FieldMolder.addValue(FieldMolder.java:268)
>         at
> org.exolab.castor.persist.CollectionProxy$ColProxy.add(ClassMolder.java:2943
> )
>         at
> org.exolab.castor.persist.ClassMolder.revertObject(ClassMolder.java:2452)
>         at
> org.exolab.castor.persist.LockEngine.revertObject(LockEngine.java:861)
>         at
> org.exolab.castor.persist.TransactionContext.rollback(TransactionContext.jav
> a:
> 1604)
>         at
> org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:502)
>         at DBTest.run(DBTest.java:42)
>         at java.lang.Thread.run(Thread.java:484)
> 17445 [Thread-0] ERROR interactive  - [ ERROR ]-[ class DBTest ]-[ at
> DBTest.run(DBTest.java:46) ]-[ Nested error:
> org.exolab.castor.jdo.LockNotGrantedException:
> persist.writeTimeoutorg.mv5.delivery.model.Server/1/0 by
> org.exolab.castor.jdo.engine.TransactionContextImpl@530cf2 ]
> org.exolab.castor.jdo.LockNotGrantedException:
> persist.writeTimeoutorg.mv5.delivery.model.Server/1/0 by
> org.exolab.castor.jdo.engine.TransactionContextImpl@530cf2
>         at
> org.exolab.castor.persist.ObjectLock.upgrade(ObjectLock.java:714)
>         at
> org.exolab.castor.persist.LockEngine$TypeInfo.upgrade(LockEngine.java:1151)
>         at
> org.exolab.castor.persist.LockEngine$TypeInfo.access$600(LockEngine.java:964
> )
>         at
> org.exolab.castor.persist.LockEngine.writeLock(LockEngine.java:806)
>         at
> org.exolab.castor.persist.TransactionContext.writeLock(TransactionContext.ja
> va
>:1183)
>         at
> org.exolab.castor.persist.ClassMolder.preStore(ClassMolder.java:1504)
>         at
> org.exolab.castor.persist.LockEngine.preStore(LockEngine.java:724)
>         at
> org.exolab.castor.persist.TransactionContext.prepare(TransactionContext.java
>:1
> 360)
>         at
> org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:499)
>         at DBTest.run(DBTest.java:42)
>         at java.lang.Thread.run(Thread.java:484)
> 
> 
> Now, my server object is fairly complicated...  and I include the xml for
> it
> in here. (See bottom of email.)  I'm not sure on why this is happening, and
> I'm looking for fixes or workarounds.  Any help is appreciated.  (I can
> send
> more data has requested.)
> 
>   <class name="org.mv5.delivery.model.Server" 
>          identity="id"
>          key-generator="SEQUENCE">
>     <cache-type type="none"/>
>     <description>Server info</description>
>     <map-to table="server" />
>     <field name="id" type="integer">
>          <sql name="server_id" type="integer"/>
>     </field>
>     <field name="data" type="org.mv5.delivery.model.ServerData">
>        <sql name="server_data_id"/>
>     </field>
>     <field name="downstreamservers"
> type="org.mv5.delivery.model.RemoteServer"
>            collection="collection"/>
>     <field name="dirs" type="org.mv5.delivery.model.Dir"
>            collection="collection"/>
>     <field name="jarfiles" type="org.mv5.delivery.model.Jarfile"
>            collection="collection" lazy="true"/>
>     <field name="prefs" type="org.mv5.delivery.model.Prefs">
>        <sql name="prefs_id"/>
>     </field>
>   </class>
> 
> 
> 
> 
> 
> Virtually, 
> Ned Wolpert <[EMAIL PROTECTED]>
> 
> D08C2F45:  28E7 56CB 58AC C622 5A51  3C42 8B2B 2739 D08C 2F45 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
> 
> iD8DBQE78ESHiysnOdCML0URAlsyAJ9u5qRDTP2dKPYn6sRr90rV4GscgwCfRLOb
> G+wEhmOm5JKNZNtf9ZQWBZs=
> =CNKS
> -----END PGP SIGNATURE-----
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>       unsubscribe castor-dev


Virtually, 
Ned Wolpert <[EMAIL PROTECTED]>

D08C2F45:  28E7 56CB 58AC C622 5A51  3C42 8B2B 2739 D08C 2F45 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE78EtqiysnOdCML0URAr/DAJ9L210roRYN6RTXEUnsRT3MFsm/1ACfcBfo
XWSxkHE6CfolkFPgGFinD0g=
=Ea4E
-----END PGP SIGNATURE-----

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to