-
1. Re: Error while calling EJB from Servlet
vashistvishal Sep 6, 2003 9:05 PM (in response to srshende)
private ActivityHome getHome() throws NamingException {
Object result = getContext().lookup(ActivityHome.JNDI_NAME);
return ( (ActivityHome) PortableRemoteObject.narrow(result,ActivityHome.class));
}
Note :: JNDI_NAME will be something ActivityHomeBean
private InitialContext getContext() throws NamingException {
Hashtable props = new Hashtable();
props.put(
InitialContext.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
InitialContext initialContext = new InitialContext(props);
return initialContext;
}
Try this way, its just that i have made it in diffrent methods. You can put debug staements in bot themethods and can see where it is failing. I can ser that yr JNDI_NAME is wrong like "Activity/activity".
Also you are typecating yr ActivityHome in craete call.
Thers is no need for that because home interface's create call returns the reference to remote object interface in this case it is called Activity.
So just do
Activity myBean = getHome().create();
I hope all this helps you with.
Cheers.......
Vishal -
2. Re: Error while calling EJB from Servlet
wmprice Sep 7, 2003 9:20 PM (in response to srshende)The problem is not looking up a reference to the ejb, the problem is in compiling your Servlet. The compiler is telling you that it cannot find the appropriate javax.ejb.* classes and thus it is failing. You need to reference jbossall-client.jar on your compilation classpath. You can find this jar in your $JBOSS_HOME/client/ directory.
Regards,
Weston