aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Problem while running a client 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 "Problem while running a client" Watch "Problem while running a client" New topic
Author

Problem while running a client

vikram veera
Ranch Hand

Joined: Dec 26, 2000
Posts: 43

Hello,
I am new to ejb ,I had a problem while running a client ,I through a exception by name javax.Naming.Exception:ClassNamenotfound.
I am using stateless session bean in weblogic server.Using DDCreator utility,i created manifest and jar file sussesfully.
And also i changed weblogic property file.
My program is given below:
1)
import javax.ejb.*;
import java.rmi.*;
public interface Hello extends EJBObject
{
String sayHello(String s) throws RemoteException;
}
2)
import javax.ejb.*;
public interface HelloHome extends EJBHome
{
public Hello create() throws java.rmi.RemoteException,
javax.ejb.CreateException;
}

3)
import javax.ejb.*;
public class HelloBean implements SessionBean
{
SessionContext ctx;
public void ejbCreate()
{
}
public String sayHello(String s)
{
return "Hello There,"+s;
}
public void ejbRemove()
{
}
public void ejbPassivate()
{
}
public void ejbActivate()
{
}
public void setSessionContext(SessionContext ctx)
{
this.ctx = ctx;
}
}
4)
Client program
import java.rmi.*;
import javax.naming.*;
public class HelloClient
{
public static void main(String arg[])
{
try
{
InitialContext ic = new InitialContext();
HelloHome home=(HelloHome) ic.lookup("HelloHome");
Hello hel= home.create();
String retval=hel.sayHello("VIKRAM");
System.out.println("returned:"+retval);
hel.remove();
}
catch(java.rmi.RemoteException e)
{
System.out.println("remote exception occured:"+e);
}
catch(javax.ejb.CreateException e)
{
System.out.println("create exception occured:"+e);
}
catch(javax.ejb.RemoveException e)
{
System.out.println("remote exception occured:"+e);
}
catch(javax.naming.NamingException e)
{
System.out.println("naming exception occured:"+e);
}
}
}
all the programs I am writing in the directory by name
d:\ejb including client.I am compiling all the program in the same directory.
If i write package statement in the program i can't able to create
DD.ser file.
Please help me in this problem.wheater i have to import any other
things to the client program.
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
No Vikram,
U have to have all u'r classes in the right directories or else u'r system will not work.
Please read the Weblogic server documentation at the bea site and then try to put the files in the appropriate folders and then set u'r classpath such that those files/packages are there in the classpath.
HTH
Sahil


Adios
vikram veera
Ranch Hand

Joined: Dec 26, 2000
Posts: 43
Hello,
I set my classpath properyly.Again It gives me a exception saying
javax.naming.NameNotFoundException:'HelloHome';Remaining Name:
'HelloHome'.
Please help me in this.I also change my weblogic property file
ie weblogic.ejb.deploy=/d:\weblogic\classes\HelloBean.jar;/
d:\weblogic is the directory where i store weblogic server.
I am using weblogic 4.5.1 server.Because of that i gives me error or
else i have to use higher version.
from
vikram
Anjana Rao
Greenhorn

Joined: Jan 25, 2001
Posts: 14
hi vikram,
please check out the jndi name that u r assigning to your bean while deploying it. You get the NAmeNotFoundException when u make a lookup through your client code for a wrong name.
Just make a check for the same. Your code will work.
Anjana
Mrigasira Srinivas
Greenhorn

Joined: Feb 28, 2001
Posts: 17
Hi Vikram
You get the name not found exception when the jndi name you have given in your client is different from the one you mentioned in your descriptor. Check both the jndi names. In fact, when you deploy the bean in weblogic, on the server you can see the jndi name that your home interface is bound to. Probably that will give you an idea as to where you are going wrong. Do revert if you have any queries.
Yamini
 
jQuery in Action, 2nd edition
 
subject: Problem while running a client