aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Please provide a some code for looking up EJB from a simple class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Please provide a some code for looking up EJB from a simple class" Watch "Please provide a some code for looking up EJB from a simple class" New topic
Author

Please provide a some code for looking up EJB from a simple class

Caesar Dutta
Ranch Hand

Joined: Sep 18, 2004
Posts: 30
Date: 18 September, 2004

Hi all,

I am very new to EJB and JNDI. I know only how to write simple stateful
and stateless session bean using Sun Java System Application Server.

I have written a very simple stateful bean which has only one business
method getMyName() and returns "Caesar".

The name of EJB in ejb-jar.xml is "SimpleStatefulEJB" and the jndi name
in sun-ejb-jar.xml is "TheSSEJB".

All I now want is this. I will have a simple JAVA class which can call this EJB.

Can anybody provide me some few line of code with instructions.

Your help will be highly appreciated.

Thanks in advance -

Caesar
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31075
    
233

Caesar,
Welcome to Javaranch!

Sun's online book walks you through the syntax of the application client.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Caesar Dutta
Ranch Hand

Joined: Sep 18, 2004
Posts: 30
Thanks Jeanne. I did went through the tutorial. My problem is
this line -
Context myEnv = Context)initial.lookup("java:comp/env");

What is ths "java:comp/env" ??? I can understand the latter part ejb/jndiname because I know that I am setting that in sun-ejb-jar.xml with
reference to my bean.

I have solved my problem actually by using this:
InitialContext ic = new InitialContext();
Object homeObj = ic.lookup("corbaname:iiop:1.2@localhost:3700#TheSayMyName");

Well only thing I understand is 3700 the RMI-IIOP port and the JNDI name
of my bean "TheSayMyName" as appears in sun-ejb-jar.xml.

But what about the rest? If I would have not found the piece of code from
internet then how to know that string?

I am coming across lot of example in the internet where they are first
creating a Initial naming context and putting some values (url type) in
properties and then suing that properties class to create initial context.

I just cannot understand those strings?

Please help.

Thanks again,

Caesar
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31075
    
233

Caesar,
"java:comp/env" is an environmental context. The initial context can contain other contexts (think of them as buckets.) The application server puts all your EJBs in one bucket.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please provide a some code for looking up EJB from a simple class