Remote EJB
jbossadmin_007 Jan 11, 2012 10:47 PMHello,
I am currently attempting to learn EJBs (with JBoss 5.1), however I am having some trouble with classpath (I guess). I have a simple EJB client and server jar (From the EJB 3 in Action book code samples [1]). I deploy the server jar to JBoss and call it from the client outside JBoss (remote) via the following command:
java -jar myEjbClient.jar -classpath /home/jdoe/Desktop/jboss-5.1.0.GA/lib/*.jar /home/jdoe/Desktop/jboss-5.1.0.GA/common/lib/*.jar /home/jdoe/Desktop/jboss-5.1.0.GA/server/default/deployers/ejb3.deployer/*.jar /home/jdoe/Desktop/jboss-5.1.0.GA/server/default/deployers/jboss-aop-jboss5.deployer/*.jar /home/jdoe/Desktop/jboss-5.1.0.GA/client/*.jar
As you can see, I place pretty much everthing on the classpath, but I keep running into:
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
at javax.naming.InitialContext.init(InitialContext.java:240)
at javax.naming.InitialContext.<init>(InitialContext.java:214)
at com.ejb3inaction.actionbazaar.client.HelloUserClient.main(HelloUserClient.java:20)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:63)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:671)
... 4 more
How am I getting "java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory" when jnpserver.jar (which contains this class) is on the classpath (common/lib directory)
*FYI, I didnt use jndi.properties (in client jar), I used the following instead:
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,"jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "localhost:1099");
InitialContext context = new InitialContext(env);
*FYI, I have also specified an entry point in MANIFEST.MF in the client jar.
I attached both server and client jar; they also contain the source (from the book).
Thanks for your help
-jbossadmin_007
-
EJBQuestion.zip 3.6 KB