users@glassfish.java.net

EJB Client runs in Netbeans, but not outside

From: <glassfish_at_javadesktop.org>
Date: Fri, 29 Feb 2008 03:29:41 PST

Hello

I developed a simple EJB-Client, which I want to run unmanaged.

So I searched the web (and I looked at the EJB-FAQ ;-)) and came up with this:

InitialContext ic = new InitialContext();
auftragsabwicklungBean = (AuftragsabwicklungRemote) ic.lookup("beans.AuftragsabwicklungRemote");

Runs fine in netbeans, but If I run from the console I get the Exception:

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

So finally I looked into the appserv-rt.jar and changed my code to:

Properties p = new Properties(); p.put("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory"); p.put("java.naming.factory.url.pkgs","com.sun.enterprise.naming"); p.put("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
InitialContext ic = new InitialContext(p);

Runs still fine from Netbeans, but on the console I get:

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]

Has someone a clue what I sould do?

Greetings,
Jan
[Message sent by forum member 'janmueller' (janmueller)]

http://forums.java.net/jive/thread.jspa?messageID=261596