users@glassfish.java.net

NamingException thrown on Remote Interface lookup...

From: <glassfish_at_javadesktop.org>
Date: Thu, 07 Jan 2010 11:33:45 PST

Hello, I'm pretty new to EJB and have been brought onto a project to replace some consultants and add some functionality to a fairly comlex enterprise web application.

I thought I was starting to figure all this stuff out, but there's obviously something simple about looking up Stateless Session Beans using JNDI (or maybe java in general) that I don't understand.

The backend portion of our project has two major packages....

 com.us

and

 com.them

All of the class files from both packages are in the same jar which we call backend.jar.

I've already added a couple Stateless Session Beans to the project, but they have always been looked up without problem from within our package.

I've recently been trying to use a Stateless Session Bean from their package and I get a NamingException when I use InitialContext to look up the Bean's Remote Interface.

To look up the Bean I do something like this:

try {
      return new InitialContext().lookup(beanName);
    } catch (NamingException ex) {
      ex.printStackTrace();
      return null;
    }

where beanName is the name of the Bean as it appears in this annotation:

@Stateless ( name = "DispatchGroupManagerBean", mappedName = "DispatchGroupManagerBean" )
public class DispatchGroupManagerBean implements DispatchGroupManagerRemote
{
.
.
.
}


Every time I do this it throws a NamingException. If I move that code into a class in our own package it works immediately.

What confuses me is that there's another class in their package that performs lookups on beans found in our package using the same method. All the Beans in the project are defined in our package and there is one class in theirs that dynamically builds the names of our beans and looks them up using the InitialContext.

I'm trying to do everything exactly the same as they did and I get great results when I try it from any class within com.us... as soon as I move the code so that it's included from one of their classes (that seems to share all the same structure) it doesn't work.

I know I'm just mis-understanding something simple here... please help.

Here's the stack trace from our log file:


javax.naming.NamingException: ejb ref resolution error for remote business interface com.us.business.app.session.group.DispatchGroupManagerRemote [Root exception is java.lang.ClassNotFoundException: com.us.business.app.session.group.DispatchGroupManagerRemote]
   at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:425)
   at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:74)
   at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
   at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:414)
   at javax.naming.InitialContext.lookup(InitialContext.java:392)
   at com.us.business.util.Remote.getBean(Remote.java:19)
   at com.us.business.util.Remote.getDispatchGroupManagerBean(Remote.java:49)
   at com.them.lib.business.revision.RevisionManager.shouldUserReceive(RevisionManager.java:198)
   at com.them.lib.business.revision.Revision.shouldUserReceive(Revision.java:672)
   at com.them.lib.business.revision.RevisionManager.getRevisionOutput(RevisionManager.java:145)
   at com.them.lib.web.servlet.CometServlet$Handler.onEvent(CometServlet.java:36)
   at com.sun.enterprise.web.connector.grizzly.comet.DefaultNotificationHandler.notify0(DefaultNotificationHandler.java:197)
   at com.sun.enterprise.web.connector.grizzly.comet.DefaultNotificationHandler.notify0(DefaultNotificationHandler.java:125)
   at com.sun.enterprise.web.connector.grizzly.comet.DefaultNotificationHandler$1.doTask(DefaultNotificationHandler.java:112)
   at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
   at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
Caused by: java.lang.ClassNotFoundException: com.us.business.app.session.group.DispatchGroupManagerRemote
   at com.sun.appserv.server.util.ASURLClassLoader.loadClass(ASURLClassLoader.java:129)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
   at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:679)
   at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:348)
   ... 15 more


Thanks in advance for any help...
[Message sent by forum member 'jahroy' (ed_at_skilogs.com)]

http://forums.java.net/jive/thread.jspa?messageID=379398