-
1. Re: Problem with getting home object reference.
jonlee Jan 3, 2004 7:24 PM (in response to menich)Maybe I'm a bit slow with this but it is not apparent from your description what the String is that you are using for the lookup - whatever you use in ctx.lookup("...").
In any case, the error is the lookup cannot find any object by the name supplied in the string.
In theory, you are using an indirection definition so the String should be:
java:comp/env/net.menich.mypack.UserServicesHome
The lookup string, net.menich.mypack.UserServicesHome would only work if your JNDI name was net.menich.mypack.UserServicesHome. -
2. Re: Problem with getting home object reference.
menich Jan 4, 2004 6:46 AM (in response to menich)Thank's for help. In EJBHomeFactory method lookUpHome() i specified only home object class name e.g. lookUpHome(UserServicesHome.class).
In my implementation EJBHomeFactory method lookUpHome i was having:
public EJBHome lookUpHome(Class homeClass) {
EJBHome anEJBHome;
anEJBHome = (EJBHome) this.ejbHomes.get(homeClass);
try {
if(anEJBHome == null) {
anEJBHome = (EJBHome) PortableRemoteObject.narrow(ctx.lookup(homeClass.getName()), homeClass);
this.ejbHomes.put(homeClass, anEJBHome);
}
return anEJBHome;
}
when i deploy my ejb with FQ name like jndi-name, all was OK, but when i use ejb-ref tag in web.xml an jboss-web.xml, i getting NameNotFoundException. Problem was in EJBHomeFactory lookUpHome implementation. Correct form should look like this:
public EJBHome lookUpHome(Class homeClass) throws HomeFactoryException {
EJBHome anEJBHome;
anEJBHome = (EJBHome) this.ejbHomes.get(homeClass);
try {
if(anEJBHome == null) {
anEJBHome = (EJBHome) PortableRemoteObject.narrow(ctx.lookup("java:comp/env/" + homeClass.getName()), homeClass);
this.ejbHomes.put(homeClass, anEJBHome);
}
} catch (ClassCastException e) {
throw new HomeFactoryException(e);
} catch (NamingException e) {
throw new HomeFactoryException(e);
}
return anEJBHome;
}
In ctx.lookup I put jndi path java:name/comp/env/ and concat with homeClass.getName() result.
Once again thank for pay attention to add java:comp/env/ jndi context.
Regards Pawel Menich