Ok, to make it complete:

I do it like you suggested. Here is the code:

   public static MyBean loadOrCreateMyBean (MyBeanHome h, String key)
   {
      MyBean ret = null;
      try {
         try {
            ret = h.findByPrimaryKey (key);
         }
         catch (ObjectNotFoundException ex){
            log.info ("Object not found, create new one...");
         }
         if (ret == null) {
            ret = h.create (key);
         }
         return ret;
      }
      catch (Exception e) {
         log.error ("...went wrong!", e);
      }
      return ret;
   }   

The bean in the cache is ok, but the transport to DB seems to be broken...

That a vaule is missing is one part of the problem, the other is, that the
sencond execution of this code blocks the client during commit (even with
timeout settings, where the server reports the timeout, but the client still
hangs...).

Some more ideas? ... and thanks so far...Lutz


-----Original Message-----
From: Ole Husgaard [mailto:[EMAIL PROTECTED]]
Sent: Saturday, September 22, 2001 6:21 PM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] UserTransaction from client side


Hi,

Your UT lookup seems correct.
Maybe you have hit a bug in the cache like the one
reported at:
https://sourceforge.net/tracker/index.php?func=detail&aid=463548&group_id=22
866&atid=376685

If this is the case, and your loadOrCreateMyBean()
method tries to create the bean before looking it
up, you might be able to get around it by doing
it the other way: Looking it up, and then create
if not found.


Best Regards,

Ole Husgaard


Lutz Hilken wrote:
> 
> Ok, I cut the piece for getting the TA: it's this:
> 
>    public static UserTransaction getTransaction ()
>    {
>       initContext ();
>       UserTransaction ta = null;
>       if (jndiContext != null) {
>          try {
>             ta = (UserTransaction)jndiContext.lookup("UserTransaction");
>          }
>          catch (javax.naming.NamingException e) {
>             log.error("Exception while getting a transaction. Exception:
",
> e);
>          }
>       }
>       return ta;
>    }
> 
> ...and it's fore sure a different VM. What's funny is, that only the last
> value got lost...
> 
> -----Original Message-----
> From: Ole Husgaard [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 19, 2001 5:36 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [JBoss-user] UserTransaction from client side
> 
> Hi,
> 
> Not sure if you lookup the UT correctly.
> 
> Please be aware that the current stand-alone
> client UT _only_ works correctly if the client
> executes in a VM other than the server VM.
> 
> There is a UT test in the CTS tests in the
> jbosstest test suite.
> That may be useful as a starting point.
> 
> Best Regards,
> 
> Ole Husgaard.
> 
> Lutz Hilken wrote:
> >
> > Hi,
> >
> > I want to use Client-controlled transactions by using UserTransaction.
> When
> > testing it, some problems occured. See this code:
> >
> >          UserTransaction ta = null;
> >          try {
> >             String key = null;
> >             MyBean b = null;
> >             ta = EJBUtil.getTransaction ();
> >             ta.setTransactionTimeout(5) ;
> >             ta.begin ();
> >             MyBeanHome home = (MyBeanHome)EJBUtil.findHome ("MyBean");
> >             boolean doRollback = args[0].equals("x");
> >             for (int i = 1; i<args.length; i++) {
> >                key = args[i];
> >                b = loadOrCreateMyBean (home, key);
> >                b.setValue ("Some vaule..."+key);
> >                log.info ("Value is: "+b.getValue());
> >             }
> >             if (doRollback) {
> >                ta.rollback();
> >             }
> >             else {
> >                ta.commit ();
> >             }
> >          }
> >          catch (Exception ex) {
> >             log.error ("...Ooops", ex);
> >             try {
> >                ta.rollback();
> >             }
> >             catch (Exception rex) {
> >                log.error ("ROLLBACK failed!", rex);
> >             }
> >          }
> >
> > Now, when calling the code the first time, the objects are created, at
> least
> > they are complete in JBoss memory cache, BUT the value of the last
created
> > bean is not present in the database!
> > The second call to this code, using the same keys updating the beans,
> hangs
> > in the commit() call and does not return, allthough the timeout is set
to
> 5
> > secs (I got a trace message on the server console, but the client keeps
> > hanging).
> >
> > What's wrong?
> >
> > I'm using JBoss 2.4.0, CMP for the beans, no specific
> Transaction-attribute
> > (so all are Required) and Oracle.
> >
> > So, please help, we need this feature urgently....
> >
> > Thanks, Lutz.
> >
> > Lutz Hilken
> > IT-Consult
> > IVU Traffic Technologies AG
> > Bundesallee 88, D-12161 Berlin
> > Telefon: +49.30.85 906-450, Telefax: +49.30.85 906-499
> > [EMAIL PROTECTED], www.ivu.de
> >
> > _______________________________________________
> > JBoss-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jboss-user
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to