Exception in thread "main" javax.naming.NameNotFoundException [Root excepti
Hi,
i'm new to EJB.
plz solve my problem Regarding NameNotFoundEXception
i used Netbeans IDE with J2EE server 8.2.i want to simply print Hello through Session bean.bt i got error when i run my client program
code of interfaces class file and client code is given below.
Home interface
package my;
import javax.ejb.*;
import java.rmi.*;
/**
*
* @author anuj.singh
*/
public interface helloHome extends EJBHome
{
public helloRemote create() throws CreateException,RemoteException;
}
Remote Interface
package my;
import javax.ejb.*;
import java.rmi.*;
/**
*
* @author anuj.singh
*/
public interface helloRemote extends EJBObject {
/** Creates a new instance of helloRemote */
public String showbean()throws RemoteException;
}
Bean class code
package my;
import javax.ejb.*;
public class hellobeanBean implements SessionBean, hellobeanLocalBusiness {
private SessionContext context;
// <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click the + sign on the left to edit the code.">
// TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
// TODO Add business methods or web service operations
/**
* @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
*/
public void setSessionContext(SessionContext aContext) {
context = aContext;
}
/**
* @see javax.ejb.SessionBean#ejbActivate()
*/
public void ejbActivate() {
}
/**
* @see javax.ejb.SessionBean#ejbPassivate()
*/
public void ejbPassivate() {
}
/**
* @see javax.ejb.SessionBean#ejbRemove()
*/
public void ejbRemove() {
}
// </editor-fold>
public void ejbCreate() {
System.out.println("hello Anuj");
}
public String showbean()
{
return("Hello Bean");
}
}
Client Code
import my.*;
import java.rmi.*;
import java.util.*;
import javax.ejb.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.lang.*;
import javax.rmi.*;
public class client {
public static void main(String args[])throws Exception
{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
props.put(Context.PROVIDER_URL, "iiop://localhost:3700");
InitialContext ctx = new InitialContext(props);
Object obj=ctx.lookup("java:comp/env/ejb/anujjndi");
my.helloHome h=(my.helloHome)PortableRemoteObject.narrow(obj,my.helloHome.class);
my.helloRemote r= h.create();
System.out.println(r.showbean());
}
}
Plz gone though it and tell me wht's exact problem.
Thanks
Anuj Singh

