Wednesday, September 3, 2014

EXP 5: Connect remote EJBs on clustered environment

Problem
Cannot connect remote EJBs on clustered enviroment (Glassfish 4 app server)

Cause
in clustered environment, Glassfish use different JNDI compare single server.

Solution
Correct JNDI as described as below:

java:globbal/<earname>/<ejbprojectname>/

You can find exactly JNDI on server.log file of Glassfish Server when it startup.

Example

java:global/gbear/gbeejb/

If EJB which you need to connect named TestEJB, the full JNDI is:

java:global/gbear/gbeejb/TestEJB

Quotes from server.log

[2014-09-03T12:48:21.608+0700] [glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: _ThreadID=14 _ThreadName=RunLevelControllerThread-1409723271247] [timeMillis: 1409723301608] [levelValue: 800] [[
  Portable JNDI names for EJB TestEJB: [java:global/gbear/gbeejb/TestEJB, java:global/gbear/gbeejb/TestEJB!com.gbsofts.gbe.module.system.service.TestService]]]

[2014-09-03T12:48:21.608+0700] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid: _ThreadID=14 _ThreadName=RunLevelControllerThread-1409723271247] [timeMillis: 1409723301608] [levelValue: 800] [[
  Glassfish-specific (Non-portable) JNDI names for EJB TestEJB: [ejb/TestEJB#com.gbsofts.gbe.module.system.service.TestService, ejb/TestEJB]]]

No comments:

Post a Comment