EJB narrow retuns null

G

Glenn

I am learning EJBs and have set up multiple server/container
environments on my machine for experimentation. I have JBoss and
SunAppServer8.1 EJB servers, and several Tomcat Web servers.

My Problem: When connecting to the SunAppServer from a "remote" Tomcat,
the PortableRemoteObject.narrow() call returns null, even though the
lookup() returned a valid IOR. However, using the same code (other than
the connection info) works correctly when calling the JBoss server.

Using the debugger I have traced my way down into the narrow() function,
and it seems to fail when trying to load a class, but I cannot make out
which class it cannot find. I have tried putting all of the relevant
libraries I could think of onto the Tomcat server, but with no effect.

Can anyone tell me:
- what causes narrow() to return null, and
- if it is a library issue, what library needs to be put where for the
SunAppServer remote EJB connection to work?

Thanks for your help.

The relevant portion of my code:

Properties p = new Properties();

// JBOSS CODE (works correctly all the way through EJB operations)
/***
p.put(
Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
p.put( Context.PROVIDER_URL, "iiop://69.142.245.162:3528" );
String objName = "Business";
****/

// SUN App Server code (gets remote object ref but fails in narrow() )
p.put(
Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory" );
p.put( Context.PROVIDER_URL, "iiop://69.142.245.162:3700" );
String objName = "ejb/Business";

InitialContext initial = new InitialContext(p);
// NOTE: InitialContext is found for BOTH JBoss AND SunAppServer

Object objref = initial.lookup(objName);
// NOTE: The lookup returns an IOR object in BOTH JBoss and SunAppServer
// and that IOR seems to be a valid object reference.

BusinessRemoteHome home =
(BusinessRemoteHome)PortableRemoteObject.narrow(objref,
BusinessRemoteHome.class);
// NOTE: When connecting to JBoss, this returns a valid object, but
// when connecting to SunAppServer, this returns null even though
// the objref is a valid IOR and the library containing
// BusinssRemoteHome.class is copied to the Tomcat server. WHY????
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top