quality@glassfish.java.net

What has changed as far as remote EJB3 invocations go?

From: Jacek Laskowski <jacek_at_laskowski.net.pl>
Date: Mon, 5 Oct 2009 11:11:32 +0200

Hi,

Here's my test code for some GFv3 testing as far as EJB3 invocation
recovery goes. After getting a remote reference to an EJB3 bean GF is
bounced a couple of times to see how that remote reference will
behave:

package pl.jaceklaskowski.javaee;

import javax.naming.Context;
import javax.naming.InitialContext;
import org.junit.Test;

public class WyswietlanieKomunikatowKlientTest {

    @Test
    public void testZdalnyKlient() throws Exception {
        Context ctx = new InitialContext();
        System.out.println("+++ Kontekst JNDI utworzony");
        WyswietlanieKomunikatow wyswietlanie =
(WyswietlanieKomunikatow) ctx.lookup("WyswietlanieKomunikatow");
        System.out.println("+++ Pobranie zdalnej referencji wykonane
poprawnie");

        for (int i = 0; i < 20; i++) {
            String iteracja = "iteracja " + (i+1);
            System.out.println(iteracja);
            try {
                wyswietlanie.wyswietl("+++ Witaj brachu! [" + iteracja + "]");
            } catch (Exception e) {
                System.out.println("--- Przechwycono wyjatek: " +
e.getLocalizedMessage());
            }
            Thread.sleep(1000 * 15);
        }
    }
}

There's nothing really unusual, just a common bunch of code
invocations to get ahold of the EJB3 remote reference and execute its
method, sleep for 15 secs and do the same for 20 iterations.

What struck me after having upgraded to GFv3 b66 was that the
try/catch block was no longer necessary. In b65, the remote invocation
failed with RemoteException when GF was down whereas b66 didn't. Did
it change and what's the issue number for it (the appropriate code
change in the GFv3 repo would be of help too)? I'm just curious what
the change was for and the reasoning behind it.

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl