We are trying to integrate Castor with J2EE App server with limited
success. We were wondering if anyone was able to do it successfully and
if there are any sample application or code available for our
references.

Specifically we trying to integrate Castor 0.9.3.9 with Orion 1.5.3 and
we are getting 
org.exolab.castor.jdo.LockNotGrantedException: persist.writeLockTimeout

The way we understand the problem there are two approaches. Long and
Short transactions explained below.

Neither of this approaches works for us. Any ideas as to what are we
doing wrong? What exactly does castor expect of us? Any feed back would
be greatly appreciated.

-- Misko & Olaf


Short Transaction approach
====================
1.) We force the orion to run ejbLoad on the begining of each
transaction.
2.) Create and updates on the Entity bean work fine and castor persists
and loads the data correctly.
3.) ejbRemove however causes the exception below. I am not sure why the
Castor feels that the object no longer is persistent even thought it was
loaded in ejbLoad method within the same transaction.

EXCEPTION:
org.exolab.castor.jdo.ObjectNotPersistentException: The object of type
com.sun.quantum.ejb.om.SoftPkg is not persistent -- it was
not queried or created within this transaction
        at
org.exolab.castor.persist.TransactionContext.delete(TransactionContext.j
ava:1107)
        at
org.exolab.castor.jdo.engine.DatabaseImpl.remove(DatabaseImpl.java:380)
        at
com.sun.quantum.ejb.entity.BaseEJB.ejbRemove(BaseEJB.java:153)
        at
SoftPkgRemote_EntityBeanWrapper0.remove(SoftPkgRemote_EntityBeanWrapper0
.java:1873)
        at
__jspPage0_TestSoftPkg_jsp._jspService(__jspPage0_TestSoftPkg_jsp.java:4
4)
        at com.orionserver.http.OrionHttpJspPage.service(.:56)
        at com.evermind._co._skc(.:5510)
        at com.evermind.server.http.JSPServlet.service(.:31)
        at com.evermind._bxb._crd(.:501)
        at com.evermind._bxb._ukb(.:170)
        at com.evermind._cn._uab(.:576)
        at com.evermind._cn._fm(.:189)
        at com.evermind._bs.run(.:62)


CODE: 
    public void ejbLoad() {
        org.exolab.castor.jdo.Database db = getDatabase();
        try{
            Integer id = (Integer)context.getPrimaryKey();
            Class clazz = getDataClass();
            data = (com.sun.quantum.ejb.om.BaseOM)db
                .load(clazz, id);
        } catch (Exception e){
            throw new javax.ejb.NoSuchEntityException(e);
        } finally{
           closeDB(db);
        }
    }
    
    public void ejbStore() {
        // Do nothing since this is a short transaction and
        // object is persistanct
    }
    
    public void ejbRemove() 
        throws javax.ejb.RemoveException
    {
        try{
            db.remove(data);
        } catch (Exception e){
            throw new javax.ejb.RemoveException(e.toString());
        } finally {
            closeDB(db);
        }
    }

Long Transaction Scenario:
==========================
1.) Long transactions would allow the possibility of the EJB to cache to
data over several transactions and would be persisted or loaded only
when it has changed.
2.) In this scenario Castor throws the exception below during ejbStore
-> db.update(data).

EXCEPTION:
org.exolab.castor.jdo.LockNotGrantedException: persist.writeLockTimeout
        at
org.exolab.castor.persist.ObjectLock.acquireUpdateLock(ObjectLock.java:5
09)
        at
org.exolab.castor.persist.LockEngine$TypeInfo.acquire(LockEngine.java:10
99)
        at
org.exolab.castor.persist.LockEngine$TypeInfo.access$1(LockEngine.java:1
030)
        at
org.exolab.castor.persist.LockEngine.update(LockEngine.java:627)
        at
org.exolab.castor.persist.TransactionContext.markUpdate(TransactionConte
xt.java:920)
        at
org.exolab.castor.persist.TransactionContext.update(TransactionContext.j
ava:991)
        at
org.exolab.castor.jdo.engine.DatabaseImpl.update(DatabaseImpl.java:353)
        at com.sun.quantum.ejb.entity.BaseEJB.ejbStore(BaseEJB.java:120)
        at
SoftPkgRemote_EntityBeanWrapper0.saveState(SoftPkgRemote_EntityBeanWrapp
er0.java:1975)
        at com.evermind.server.ejb.EntityEJBObject._rpb(.:44)
        at
com.evermind.server.ApplicationServerTransactionSynchronization._noc(.:3
86)
        at
com.evermind.server.ApplicationServerTransactionSynchronization.beforeCo
mpletion(.:540)
        at com.evermind.server.ApplicationServerTransaction._sbd(.:806)
        at
com.evermind.server.ApplicationServerTransaction.commit(.:375)
        at com.evermind.server.ApplicationServerTransaction.end(.:588)
        at
SoftPkgHome_EntityHomeWrapper1.create(SoftPkgHome_EntityHomeWrapper1.jav
a:647)
        at
__jspPage0_TestSoftPkg_jsp._jspService(__jspPage0_TestSoftPkg_jsp.java:3
6)
        at com.orionserver.http.OrionHttpJspPage.service(.:56)
        at com.evermind._co._skc(.:5510)
        at com.evermind.server.http.JSPServlet.service(.:31)
        at com.evermind._bxb._crd(.:501)
        at com.evermind._bxb._ukb(.:170)
        at com.evermind._cn._uab(.:576)
        at com.evermind._cn._fm(.:189)
        at com.evermind._bs.run(.:62)

CODE: 
    public void ejbLoad() {
        org.exolab.castor.jdo.Database db = getDatabase();
        try{
            Integer id = (Integer)context.getPrimaryKey();
            Class clazz = getDataClass();
            data = (com.sun.quantum.ejb.om.BaseOM)db
                .load(clazz, id);
        } catch (Exception e){
            throw new javax.ejb.NoSuchEntityException(e);
        } finally{
           closeDB(db);
        }
    }
    
    public void ejbStore() {
        org.exolab.castor.jdo.Database db = getDatabase();
        try{
            if (!db.isPersistent(data))
                db.update(data);
        } catch (Exception e){
            throw new javax.ejb.NoSuchEntityException(e);
        } finally{
           closeDB(db);
        }
    }
    
    public void ejbRemove() 
        throws javax.ejb.RemoveException
    {
        try{
            if (!db.isPersistent(data))
                db.update(data);
            db.remove(data);
        } catch (Exception e){
            throw new javax.ejb.RemoveException(e.toString());
        } finally {
            closeDB(db);
        }
    }


MAPPING FILE
============
  <class name='com.sun.quantum.ejb.om.SoftPkg'
         identity='iD'
         key-generator='MAX'>
    <cache-type type='unlimited'/>
    <map-to table='softpkg' />
    <field name='iD' type='integer'>
      <sql name='id' type='integer' dirty='check'/>
    </field>
    <field name='name' type='string'>
      <sql name='name' type='varchar' dirty='check'/>
    </field>
    <field name='permissionID' type='integer' required='true'>
      <sql name='permissionid' type='integer' dirty='check'/>
    </field>
    <field name='versions'
           type='com.sun.quantum.ejb.om.Version'
           collection='vector'>
      <sql many-key='softpkgid' dirty='check'/>
    </field>
  </class>

  <class name='com.sun.quantum.ejb.om.Version'
         identity='iD'
         key-generator='MAX'
         depends='com.sun.quantum.ejb.om.SoftPkg'>
    <cache-type type='unlimited'/>
    <map-to table='version' />
    <field name='iD' type='integer'>
      <sql name='id' type='integer' dirty='check'/>
    </field>
    <field name='softPkg' type='com.sun.quantum.ejb.om.SoftPkg'>
      <sql name='softpkgid' dirty='check'/>
    </field>
    <field name='implementationVersion' type='string'>
      <sql name='implementationversion' type='varchar' dirty='check'/>
    </field>
    <field name='specificationVersion' type='string'>
      <sql name='specificationversion' type='varchar' dirty='check'/>
    </field>
    <field name='licenseID' type='integer'>
      <sql name='licenseid' type='integer' dirty='check'/>
    </field>
    <field name='versionVariants'
           type='com.sun.quantum.ejb.om.VersionVariant'
           collection='vector'>
      <sql many-key='versionid'/>
    </field>
  </class>

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

Reply via email to