db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <armin.wai...@code-au-lait.de>
Subject Re: gracefuly recover from an exception in transaction.commit()
Date Sat, 04 Oct 2003 17:49:32 GMT
Hi Jair,

it's fixed in CVS. A workaround was posted
by a Gerhard Grosse:

On Thu, 2 Oct 2003 14:39:01 +0200, <Gerhard.Grosse@lex-com.net> wrote:

> I encountered a problem with class org.apache.ojb.odmg.TransactionImpl: 
> If
> a transaction is opened and committed without ever any object being
> locked, a NullPointerException is thrown at line 323 (method
> doCommitOnObjects):
>
>         if(!broker.isInTransaction()) broker.beginTransaction();
>
> I believe the fix would be to use the getBroker() method instead of
> referring to the instance variable directly:
>
>         if(!getBroker().isInTransaction()) broker.beginTransaction();
>
> Could somebody confirm this?
>
> Gerhard

regards,
Armin


On Fri, 3 Oct 2003 01:03:05 -0300, Jair da Silva Ferreira JĂșnior 
<j2@amazon.com.br> wrote:

> Hi,
>     I am using ojb1.0_rc4, ODMG api with OJB queries and mysql4. I have 
> a problem on how to recover from an exception thrown inside the commit 
> of an ODMG transaction. Please see the above example code and follow the 
> comments.
>
>     Transaction t=null;
>     try{
>         t=implementation.newTransaction();
>         t.begin();
>
>         // do something...
>
>         t.commit(); //an exception is thrown here! usually the exception 
> root cause is an SQLException
>     }
>     catch(Exception e){
>         //log exception
>         if(t!=null){
>             t.abort(); //here a NullPointerException is thrown. why?
>         }
>     }
>
>     the stack trace of the NullPointerException thrown in t.abort() is:
>         java.lang.NullPointerException
>             at org.apache.ojb.odmg.TransactionImpl.doClose(Unknown 
> Source)
>             at org.apache.ojb.odmg.TransactionImpl.abort(Unknown Source)
>             ...
>
>     Can somebody help me on how to gracefuly recover from an exception 
> in commit? Am I doing something wrong?
>
>     Any help would be appreciated.
>
> Thanks,
>     Jair Jr




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Mime
View raw message