users@glassfish.java.net

[gf-users] Local EJB call after any remote invocation

From: Eugeny Balakhonov <c0ff75_at_gmail.com>
Date: Wed, 1 Oct 2014 22:48:08 +0400

Hello

I have two Glassfish servers. One server mostly work like EJB and web-service server, second mostly work like facade web-server. Web-applications from facade web-server calls EJB beans on first server via their remote interfaces. I call remote EJB's in standard way:

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.100.176");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3701");
InitialContext ctx = new InitialContext(props);
this.op_srv = (Operations_ServiceRemote) ctx.lookup(OPERATIONS_SERVICE_NAME);

But in same time I need use JNDI for looking JDBC resources like this:

InitialContext ctx = new InitialContext();
this.ds = (DataSource) ctx.lookup("jdbc/POOL1");

But if any application on the web-server already called any remote interface then all local JNDI lookup() operations tries to work via remote calls! I.e instead of lookup of the local JDBC pool system tries to find it on the remote server. I have a lot of ClassCastExceptions in the system log file because instead of local interface I receive remote interface.

How to clear EJB call settings before local EJB/JNDI call ?

Thanks for future answers.

Eugeny