Hey Thomas,

The only way I can do this is to hardcode the autoStore value in
org.jboss.jdo.castor.CastorJDOImpl...

So, I have added a modification to this class to allow AutoStore to be set
from the jboss.jcml file.

the mbean declaration looks like this: -

  <mbean code="org.jboss.jdo.castor.CastorJDOImpl"
name="DefaultDomain:service=CastorJDO,name=JDOFactory">
     <attribute
name="Configuration">file:c://Downloaded_Software//tms_database.xml</attribu
te>
     <attribute name="JndiName">JDOFactory</attribute>
     <attribute name="LockTimeout">0</attribute>
     <attribute name="LoggingEnabled">true</attribute>
     <attribute name="CommonClassPath">false</attribute>
     <attribute name="AutoStore">true</attribute>
  </mbean>

I have tested this patch, and it behaves as expected, with relationsips only
being created when AutoStore is true. This requires no modification to any
Castor code. Attached are the relevant files. Let me know if this is an
acceptable fix,

Glenn.


-----Original Message-----
From: Thomas Yip [mailto:[EMAIL PROTECTED]]
Sent: 23 October 2001 00:47
To: Russell, Glenn
Subject: RE: Autostore in J2EE...- Stack Trace



Did you try calling setAutoStore on a JDO object, instead of on a Database
one?



Thomas


-----Original Message-----
>From: Russell, Glenn [mailto:[EMAIL PROTECTED]]
>Sent: Monday, October 22, 2001 3:03 PM
>To: '[EMAIL PROTECTED]'
>Subject: FW: Autostore in J2EE...- Stack Trace
>
>Hey Thomas,
>
>Here's the error I am getting if I try the method you mention,
>
>[CastorJDOImpl] java.lang.NullPointerException
>[CastorJDOImpl]         at
>org.exolab.castor.jdo.JDO.getDatabase(JDO.java:579)
>[CastorJDOImpl]         at
>org.jboss.jdo.castor.CastorJDOImpl.getDatabase(CastorJDOImpl.java:168)
>
>with the following code: -
>
>m_trans = ( UserTransaction ) m_ctx.lookup( "java:comp/UserTransaction" );
>//m_trans.begin();
>m_db = m_dataobjects.getDatabase();
>m_db.setAutoStore( true );
>m_trans.begin();   // Thomas said do this :-)
>
>The line I commented out above is what I had before, and which the patch I
>was talking about facilitates. Thanks again,
>
>Glenn.
>
>-----Original Message-----
>From: Russell, Glenn
>Sent: 22 October 2001 22:37
>To: 'Thomas Yip '
>Subject: RE: Autostore in J2EE...
>
>
>Yeah, that is what I thought, but trying to do so causes a
>NullPointerException.
>
>This occurs because when getDatabase() is called, Castor tries to get an
>instance of TransactionManager from JBoss, and then calls getTransaction()
>on that object, but it never gets that instance from JBoss, and there is no
>check for null in the Castor code.
>
>This all occurs before you have an instance of Database, for to be able to
>call setAutoStore.
>
>I put a fix in to get a new instance of javax.transaction.UserTransaction
in
>the getDatabase() code from JBoss, if the TransactionManager I mentioned
>above was returned as null, and this seemed to work.
>
>What avenue should I take on this?. Thanks again,
>
>Glenn.
>
>
>-----Original Message-----
>
>From: Thomas Yip
>
>To: Russell, Glenn
>
>Sent: 10/22/01 10:50 AM
>
>Subject: RE: Autostore in J2EE...
>
>
>
>
>
>AutoStore must be set before the transaction starts.
>
>I think it is documented.
>
>
>
>
>
>
>
>Thomas
>
>
>
>
>
>-----Original Message-----
>
>>From: Russell, Glenn [mailto:[EMAIL PROTECTED]]
>
>>Sent: Monday, October 22, 2001 9:00 AM
>
>>To: '[EMAIL PROTECTED]'
>
>>Subject: Autostore in J2EE...
>
>>
>
>>Hey Thomas,
>
>>
>
>>We had a problem with creating relationships being created under Castor
>
>in
>
>a
>
>>J2EE deployment. It came down to autoStore being ignored on a commit.
>
>The
>
>>following simple fix works
>
>>
>
>>in org.exolab.castor.jdo.engine.DatabaseImpl.java
>
>>
>
>>   public void setAutoStore( boolean autoStore ) {
>
>>      _autoStore = autoStore;
>
>>   }
>
>>
>
>>becomes: -
>
>>
>
>>   public void setAutoStore( boolean autoStore ) {
>
>>      if( _ctx != null ) {
>
>>         _ctx.setAutoStore( autoStore );
>
>>      }
>
>>     _autoStore = autoStore;
>
>>   }
>
>>
>
>>I am having trouble setting up the JUnit tests for Castor CVS,
>
>otherwise I
>
>>would test this before sending this patch. If there is a problem, with
>
>it,
>
>I
>
>>will happily investigate and revise. Thanks,
>
>>
>
>>Glenn.
>
>>
>
>>Glenn Russell
>
>>Systems Analyst,
>
>>Spirent Systems Belfast,
>
>>Howard House,
>
>>Belfast
>
>>
>
>>"Ni"
>
>>The Knights of Ni
>
>>
>

jbosscastor-modified.jar

CastorJDOImpl.java

CastorJDOImplMBean.java

Reply via email to