users@glassfish.java.net

problem accessing remote ejb and a strange fact

From: <glassfish_at_javadesktop.org>
Date: Wed, 20 Jun 2007 09:02:49 PDT

Hi all,

I'm quite new to distributed applications.

I have two stand-alone instances of Glassfish (v2 Beta 2 the first one; v1, current release, the second one) running on different machines ("hostV2" and "hostV1").

I have an ejb module with business logic deployed on hostV2, and my web application running on hostV1.

I'm trying to access a remote stateless session ejb from a servlet in the web application.

I've followed this faq: https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#cross-appserverremoteref

My remote ejb has, obviously, a remote interface and also has a mappedName attribute:

...
@Interceptors(com.mydomain.interceptors.MyInterceptor.class)
@Stateless(mappedName="ejb/MyStatelessBean")
...

My servlet (in the web application) has these lines of code:

...
@EJB(name="ejb/MyStatelessBeanRef")
private MyStatelessRemote myStatelessBean;
...

I've put in sun-web.xml an ejb-ref node:

...
<ejb-ref>
  <ejb-ref-name>ejb/MyStatelessBeanRef</ejb-ref-name>
  <jndi-name>corbaname:iiop:<hostV2 ip address>:3700#ejb/MyStatelessBean</jndi-name>
</ejb-ref>
...

Well, it doesn't work... :-(

This is the thrown exception

---
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref ejb/MyStatelessBeanRef_at_jndi: corbaname:iiop:<hostV2 ip address>:3700#ejb/MyStatelessBean_at_null@com.mydomain.beans.ejb.MyStatelessRemote_at_Session@null into class com.mydomain.presentation.MyServlet
javax.naming.NameNotFoundException: No object bound for java:comp/env/ejb/MyStatelessBeanRef [Root exception is org.omg.CORBA.BAD_PARAM:   vmcid: OMG  minor code: 9  completed: No]
---
*** BUT THE STRANGE FACT *** is that ALL works properly if I deploy ejb-module and web application on the same app serv (hostV2).
I've also reproduced the error with the two modules running on the same app serv: I've VOLUNTARILY made an error in writing the value of jndi-name node in sun-web.xml; I've changed "MyStatelessBean" into "MyStatelessBea" (without final "n"). The error's occurred "properly"... :-)
I can't understand... Can anyone help me?
Thanks in advance!
emilio
[Message sent by forum member 'emilioremogna' (emilioremogna)]
http://forums.java.net/jive/thread.jspa?messageID=223101