users@glassfish.java.net

Re: EJB3 Remote Referece Thread Safe?

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Fri, 17 Oct 2008 16:30:05 +0200

Well, just forget about looking the reference up always, just wrap
your reference with interceptor like I did. It intercepts EVERY SINGLE
method call and it does check for EJB exceptions (you can use CGLIB,
but I think, the standard Java classes from java.lang.reflect package
should do the job as well).

So, when specific exception occurs, just look up the object again and
you are done. In your case, when there are many threads which can
actually invoke a method on your proxy - you have either to
synchronize calls inside your interceptor or maybe just serialize
them.
You should, by the way, fill up an issue for Glassfish with your failing test.

Regards,
Witold Szczerba

2008/10/17 <glassfish_at_javadesktop.org>:
> First af all, thanks a lot for your time and your samples.
>
> The good news are that the client is still alive, and the damn CORBA Exception has not raised for 2 days.
>
> My test environment, has really two clients that are making a call to the same ejb3 remote method every 30 seconds since they were started (I've implemented this using a Timer). The first client does just one lookup, and usues the EJB3 remote reference through the entire live of the application. The second client (based on your suggestion), performs a lookup each time it needs to call a method, i.e. gets a "fresh reference" every 30 seconds.
>
> Well, let's comment the results: The first client gets random CORBA Exception (I've already put the stack trace before), so the call is blocked until the exception is rised (30 minute!!!). The second client is still alive since the first run (2 days till now) and of course has not suffer from any weird exception.
>
> I do not know the reason, but it's just that simple to reproduce the problem. And the workaround of getting a fresh reference is good, but I'm just wondering if there could be an issue with this procedure of getting a "fresh reference" each time you need to call a method. Notice two things:
> 1. The client lives forever, it's a monitoring app that needs to be up always.
> 2. I can`t do the same you do, Witold, because you have very clear when you need to get a "fresh reference" (new child window pops up), and when you have to dispose it (child window closes). In my application the main frame window has to call remote ejb methods in response of 3 things:
> - User interaction ----> Indeterminate time
> - JMS message reception ----> Indeterminate time
> - A Timer ----> Determinate time
> ...so when should I get the "fresh reference"?:
> - Every time ----> Ok if no problems according to multiple lookups of the same reference (each time i need to call a method)
> - Every n seconds or every n calls ----> Problem, because perhaps "n-1" or "n-2" or "n",...is the call that gets the damn exception, and blocks (30 minutes default!)
> [Message sent by forum member 'abelmj' (abelmj)]
>
> http://forums.java.net/jive/thread.jspa?messageID=308611
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>