This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB and other Java EE Technologies and the fly likes EJB problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB problem" Watch "EJB problem" New topic
Author

EJB problem

Chris Chua
Greenhorn

Joined: Feb 21, 2001
Posts: 24
Hi to all I have a simple problem with EJB what i wanted is to get the reference of another Enterprise bean I have used this code in my Bean class
Context con = new InitialContext()
Context enviroment = (Context) con.lookup("java:comp/env/nameofbean");
otherBeanHome home = (otherBeanHome) enviroment.lookup("name");
i have already set the reference area in the deployment tool however when i ran it it throws an exception NoClassDefError
I tried another code to call the other bean like
Context con = new InitialContext();
Object objectRef = con.lookup("name");
otherBeanHome home = (OtherBeanHome) PortableRemoteObject.narrow(objectRef, otherBeanHome.class);
otherBean bean = home.create();
this code still throws the NoClassDefError could somebody pls help me by explaining what i should do to get an reference of another enterprise bean. I am using the j2sdkee1.3 server
Thanks in advance
Thanks Chris

[This message has been edited by Chris Chua (edited August 27, 2001).]
Mahesh Kulkarni
Ranch Hand

Joined: Jul 05, 2001
Posts: 62
Hi Chris,
Write a simple method as follows.
static public Context getInitialContext() throws Exception
{
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.TengahInitialContextFactory");
return new InitialContext(p);
}

Call this method as follows in EjbCreate/or in a seperate method and call that method in EJBCreate(if in seperate method)
try
{
ictx=getInitialContext();
home=(OtherBeanHome) ictx.lookup("name");
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
Thanx
Mahesh
Chris Chua
Greenhorn

Joined: Feb 21, 2001
Posts: 24
Hi Mahesh
Thanks for your reply, but I think that works with weblogic server only. Some things are vendor specific, could you help me with some code that would work in j2sdkee1.3 server?
Thanks
Chris
rajesh boorla
Greenhorn

Joined: Sep 01, 2001
Posts: 3
Hi,
I am learning ejbs and i have deployed simple ejb in websphere3.5 successfully but when i am running the client program i am getting the error :
java.lang.NoClassDefFoundError rg/omg/Cosnaming/NamingContextOpertaion
so can any body help me in solving this problem
rajesh.
rajesh boorla
Greenhorn

Joined: Sep 01, 2001
Posts: 3
Hi all,
I am learning ejbs and i have deployed my ejb sucessfully in websphere 3.5 when i am trying to run my client program i am getting the error:
javax.naming.CommunicationException:can't find serial context provider
so can any body help me to solve the problem.
rajesh.
srilatha kodati
Greenhorn

Joined: Sep 01, 2001
Posts: 2
Hi all,
I am learning ejbs and i have deployed successfully in websphere3.5 but when i try to run my client program i am getting the error:
javax.naming.CommunicationException:can't find serialcontextprovider
so if any body knows how to solve the problem please let me know....
srilatha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB problem