Cannot get JNDI context bindings for existing EJBs
pgraf1404 Sep 21, 2004 9:40 AMI am trying to web service-expose our J2EE server-side API which is largely composed of the public methods on about 10 stateless session EJBs. My initial interest is to expose key methods in our Authentication and Object Model EJBs. A desired goal with this web services project is to web service-expose our existing J2EE APIs without touching the existing J2EE app's code/configuration itself.
I have successfully constructed an Axis 1.1 application within our application's development environment - JBoss 3.0.1, Tomcat 4.0.4, using JDK 1.4.2. This small application is a web services wrapper stateless session EJB. I've been successful in getting the J2EE app's initial context and login context but am at a roadblock with getting the Axis application to "see" the JNDI context of the existing J2EE app. in order to access it's EJBs. I am unsure of proper integration, ejb-ref, and JNDI lookup param settings to enter into the Tomcat server.xml and into the web service app's ejb-jar.xml and web.xml config files to get the web service app to "see" the EJBS in the app.
Here are the JNDI bindings that are available once the J2EE app's initial context and login context are obtained:
DEBUG: context.list() context bindings list follows...
XAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
UserTransactionSessionFactory: org.jboss.tm.usertx.server.UserTransactionSessionFactoryImpl
RMIXAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
jmx:PEEKAMOOSE:rmi: org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl
topic: org.jnp.interfaces.NamingContext
queue: org.jnp.interfaces.NamingContext
ConnectionFactory: org.jboss.mq.SpyConnectionFactory
RMIConnectionFactory: org.jboss.mq.SpyConnectionFactory
UserTransaction: org.jboss.tm.usertx.client.ClientUserTransaction
local: org.jnp.interfaces.NamingContext
ejb: org.jnp.interfaces.NamingContext
invokers: org.jnp.interfaces.NamingContext
UILXAConnectionFactory: org.jboss.mq.SpyXAConnectionFactory
UILConnectionFactory: org.jboss.mq.SpyConnectionFactory
With the J2EE app's initial context in hand, executing this code...
/**
* Create and return the Object Model bean
* @return The OM bean
*/
private ObjectModel getObjectModel(Context jndiContext)
{
ObjectModel om = null;
try
{
// Get a reference to the OM Bean
Object ref = jndiContext.lookup("java:comp/env/ejb/ObjectModel");
System.out.println("DEBUG: jndiContext lookup was successful.");
// Get a reference from this to the Bean's Home interface
ObjectModelHome home = (ObjectModelHome) PortableRemoteObject.narrow(ref, ObjectModelHome.class);
System.out.println("DEBUG: obtained ObjectModelHome reference successfully.");
// Create an Interest object from the Home interface
om = home.create();
System.out.println("DEBUG: home.create() method executed successfully.");
}
catch (Exception e)
{
System.out.println("jndiContext lookup failed - could not get object model bean.");
e.printStackTrace();
om = null;
}
return om;
}
gives the error:
jndiContext lookup failed - could not get object model bean.
javax.naming.NameNotFoundException: ejb not bound
Any ideas/tips you may have re: this situation would be appreciated!
Thanks, Paul