JNDI declaration for beans used by remote clients?

Hi.

I'm completely ok with the concept of EARs, WARs and EJB JARs and all their deployment descriptors, but one thing fails me.

If I deploy a web application (JSPs, servles, HTML) I can specify in the web.xml file any ejb-ref statements so that the servlets/JSPs can access the EJBs in the ejb jar file (all within an EAR file with the relevant application.xml etc) and all works fine. HOWEVER, what I dont understand (and have been unable to get a clear answer on) is how a remote client is supposed to access an EJB deployed on an AS. It is not part of the WAR file so it cannot share the information contained in the web.xml file (such as the ejb-ref part defining the jndi name) so how does it perform a lookup? Am I missing something?

Does anyone out there have example application.xml, web.xml and ejb-jar.xml files for deploying a simple session bean that can be used by a remote client (ie, client is NOT on the server and NOT specified within any descriptor file within the EAR file - and yes, I know you have to setup the environment on the client so that it can connect to the JNDI service on the app server, and that this is vendor specific).

Thank you to whomever can provide a good answer!

Andy

[1254 byte] By [andymoose] at [2007-9-27 2:53:30]
# 1

Hmmm.....

I'm beginning to think I know the answer to my own question. Having just looked at the Sun Reference Implementation, and used the deployer tool, I specified a jndi name for my single session bean and saved the project. I then took a peak inside the ear file and along with application.xml there was also a sun-j2ee-ri.xml file, and inside that there is some sun ri specific stuff and lo and behold, the jndi name....

So this is most likely a vendor specific thing. Looks like the standard descriptors allow for telling the container about what beans are referenced by other beans, but not what the "visible-to-the-remote-client" bean's jndi name is. This seems to be left to the specific AS that you are using.

Correct me if I'm wrong. Please....

Andy

andymoose at 2007-7-4 23:18:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

I'm using Iplanet 6 and my beans are used by another application already installed. I simply deploy the .jar files by themselves as separate modules ( deploy module ). These are deployed to a modules directory under the app server's APPS path.

I access the session bean by getting a Context on the client and performing a lookup on the name of my session bean:

Context initial = new InitialContext();

UserManager um = (UserManager)initial.lookup("ebj/UserManagerBean");

The session bean holds references to all my entity beans and this all seems to work fine.

The ejb-jar.xml file simply holds the references to the entity beans and the ejb name, home, remote,class,session type and transaction type for the session bean itself. My deploytool creates an app server specifc dd with timeouts and other stuff in it.... apart from that - that seems to be it!

stipper at 2007-7-4 23:18:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

"The ejb-jar.xml file simply holds the references to the entity beans and the ejb name, home, remote,class,session type and transaction type for the session bean itself."

so where is it that you are getting this jndi lookup name for your session bean then? Where is the "ejb/UsermanagerBean" reference delared. If only the entity bean jndi names are declared in your ejb-jar.xml file then is the app server specific DD being used to declare that session bean jndi name?

I am trying to use a session bean sitting on my application server through a java swing client app that has in no way got anything to do with the application server or the DD for the session bean deployed on that server.

My session bean doesnt use any entity beans or other session beans. It is the only bean in the application. Therefore the ejb-jar.xml file is pretty minimalist, and does not declare any jndi information in it as there are no ejb-refs.

So, there you have a lone session bean, sitting in a jar by itself, along with its DD. Then you have that jar inside of an ear file, and the application.xml DD simply has a

<module>

<ejb>mysessionbean.jar</ejb>

</module>

section in it.

So far no jndi declarations at all. So, one might wonder, how in the name of all that is good and compilable might someone use this bean?

The Sun RI deploy tool creates a sun ri specific xml DD that sits inside the ear file, and in that you can declare the jndi lookup name for the bean (note, this is NOT a reference to another bean, but the actual bean's reference itself) .....is this how it works for all app servers? Is there something in the application.xml DD that I have missed...some sort of extra tag that specifies the session beans jndi name? Or is it simply not necessary, as the session bean assumes a default jndi name of "ejb/<bean home class name>".

Andy

andymoose at 2007-7-4 23:18:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Andy,

the name "ejb/UserManagerBean" is the iplanet standard lookup for a bean... i.e. "ejb/beanName"

I don't declare the lookup name for the session bean anywhere, the appserver knows to look for UserManagerBean because it's prefixed with the standard ejb/...

hope this helps

sharon

stipper at 2007-7-4 23:18:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
Hi. Thanks for the reply.Ok. That would explain why I have to use the declared ejb name from the ejb-jar.xml file as the lookup name when doing lookups from outside the AS.Have some Dukes :-)
andymoose at 2007-7-4 23:18:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...