I am having all sorts of problems doing an InitialContext.lookup() of an
EJB home interface from a Tomcat servlet. I'm using JBoss 2.0 final,
Tomcat 3.2.1, and running Tomcat **standalone** -- not embedded in
JBoss. I have the same thing working just fine in a standalone application
(i.e. not a servlet). It seems that Tomcat is not able to locate my jboss
client jars or the jndi.properties file from the WAR file. I've tried
every combination I can think of, but cannot get it to work. As an example...
Running Tomcat with the following system classpath:
- ant.jar, jasper.jar, jaxp.jar, parser.jar, servlet.jar from Tomcat lib,
and jaas.jar
My .war file contains: (among other things):
- in WEB-INF\classes:
EJB interface files, including SkillHome.class, the EJB that I'm
trying to access.
jndi.properties
- in WEB-INF\lib: (among other things)
ejb.jar
jboss-client.jar
jnp-client.jar
jta-spec1_0_1.jar
When I run Tomcat, I'm able to run my servlet and JSPs. When the following
code runs, I get the following exception:
Object ref = new InitialContext(icProps).lookup(SkillHome.JNDI_NAME);
skillHome = (SkillHome)PortableRemoteObject.narrow(ref,SkillHome.class);
Cannot instantiate class: org.jnp.interfaces.NamingContextFactory
javax.naming.NoInitialContextException: Cannot instantiate class:
org.jnp.interfaces.NamingContextFactory. Root exception is
java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at
com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:45)
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:655)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
at javax.naming.InitialContext.init(InitialContext.java:222)
at javax.naming.InitialContext.<init>(InitialContext.java:198)
at
com.ejbpeople.servlet.action.SaveSkillAction.getSkillHome(SaveSkillAction.java:179)
at
com.ejbpeople.servlet.action.SaveSkillAction.createSkill(aveSkillAction.java:212)
at
com.ejbpeople.servlet.action.SaveSkillAction.perform(SaveSkillAction.java:143)
at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1617)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1427)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:481)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
This is really weird because jnp-client.jar is definitely in WEB-INF\lib in
my WAR file.
I then tried putting the JBoss client JARS on the system classpath just to
see if I could get it to work. I got past the first problem (it finds
org.jnp.interfaces.NamingContextFactory), but then is unable to find my EJB
Home class, com.ejbpeople.ejb.skill.SkillHome.
javax.naming.CommunicationException. Root exception is
java.lang.ClassNotFoundException: com.ejbpeople.ejb.skill.SkillHome
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:484)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.rmi.MarshalledObject.get(MarshalledObject.java:138)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:299)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:279)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at
com.ejbpeople.servlet.action.SaveSkillAction.getSkillHome(SaveSkillAction.java:179)
at
com.ejbpeople.servlet.action.SaveSkillAction.createSkill(SaveSkillAction.java:212)
at
com.ejbpeople.servlet.action.SaveSkillAction.perform(SaveSkillAction.java:143)
at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1617)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1427)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:481)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
I've tried all sorts of different options for my EJB interface files,
including:
- in a JAR file in the WEB-INF\lib directory
- in the WEB-INF\classes directory
- on the system classpath
Nothing seems to allow Tomcat to locate the EJB home interface class...
I'm also unable to get Tomcat to locate my jndi.properties file, even
though I put it in all the same places, the classes directory, the lib
directory of the WAR file, and on the system classpath of Tomcat. Then I
resorted to passing the JNDI properties via java VM params. This succeeded
in getting the properties read (I could tell by executing a
System.getProperties() call and examining the props), but they were being
ignored by the "new InitialContext()" call. I had to store them into a
Properties object "by hand" before calling "new InitialContext()".
Can somebody please help...I just spent around 4 straight hours on this and
could really use some help.
Thanks,
Rick
--------------------
Rick Horowitz
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]