Remote EJB lookup

asim252 used Ask the Experts™

I have an application that resides in an EAR which communicates with numerous interfaces (remote Ejb's 3).

I have created classes to mock these interfaces and have them wrapped in a separate EAR.

Both of these EARS are deployed on the same WAS7 instance.

Im expecting the code below to throw a runtime exception however using the initialContext my client code cannot find the RemoteEJB interface. I get a the following error:

javax.naming.NameNotFoundException: Name "comp/env/cmsLookupRemote_per" not found in context "java:".

im pulling in the jndi address from a config file.

Can anyone assist in how I can call a remote Ejb using the initial context that lives in the same WAS instance however in another EAR file.

Cheers in advance!

public class CMSTestHarness extends EJB3TestHarness implements CMSRemote {
      public CityDto[] getAllCitiesDesc() throws WsException
            throw new RuntimeException("NOT IMPLEMENTED");

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009

Can you lookup the mocked EJB classes from a standalone client?

Usually I do the lookup by earname/SessionBean Name/remote; I am using JBoss.
youre trying "application local" scope lookups (java:comp/env) between different jars. try looking up the global-JNDI names for the beans youre after.
if youre not sure what they are either grep for them in the server boot log or (in case of jboss) use the JNDI-view available through the JMS console.
the structure of jboss global JNDI names is [ear file name]/[bean class name]/remote (for remote interfaces). for local interfaces replace /remote with /local
for other application servers, i dont know what the global-jndi structure, sorry.
Thanks for the reply guys.

I found the solution a short time after posting.

Initially I checked the websphere admin console to find what the EJB3 jndi names were for the beans with no joy as these remote beans were listed but jndi binding names not given. It was only after doing some more googling that I came across another forum suggesting to check the Websphere server log. It was here that I found all my bindings.

Thanks again for your advice :)


Found solution shortly after posting.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial