Hi all,
I'd really appreciate some help understanding how to make jndi.properties in
a webapp point at the jboss naming service.
I have a web app that deploys and runs fine on the integrated JBoss/tomcat
stack. I'm trying to reconfigure this so that tomcat runs independently. My
problem is in obtaining an initial naming context to look up my EJBs. If I
set the naming environment properties in code it works fine, but I'd like to
avoid having to set them this way. When trying to look up an EJB from the
webapp I get: -
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
jndi.properties file is in the WEB-INF/classes directory. I'm fairly sure
tomcat can find my jndi.properties as it successfully finds other properties
files in that directory.
Any help would be massively appreciated. Version info, code and full stack
trace below: -
Running JBoss 2.2.2, Tomcat 3.2.2 on Win98. JDK1.3
The code (part of file PersonSearchAction.java, a struts Action class):
/* This way works
java.util.Properties env = new java.util.Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.setProperty(Context.PROVIDER_URL, "localhost:1099");
env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming");
Context ic=new InitialContext(env);
*/
/* Commented out when block above uncommented... */
Context ic = new InitialContext();
Object objref = ic.lookup("PersonEJB");
PersonHome home =
(PersonHome) PortableRemoteObject.narrow(objref,
PersonHome.class);
Collection all = home.findAll();
jndi.properties:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming
Stack trace:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:646)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:283)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at
com.paribus.hemlatta.clients.people.PersonSearchAction.perform(PersonSearchA
ction.java:84)
...
Thanks,
Jim
[EMAIL PROTECTED]
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user