Forums Register Login

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

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Caesar,
Welcome to Javaranch!

Sun's online book walks you through the syntax of the application client.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 756 times.
Similar Threads
A Simple CMP Bean deployment problem in Bea WebLogic 8.0
A Simple CMP Bean deployment problem in Bea WebLogic 8.0
EJB3.1-Weblogic12C. Problem creating dummy orb: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code
writing deployment descriptor
How do I implement BOTH a local and a remote client view for a bean?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:12:59.