Who can tell me what lead to this strange error?
wprusty Sep 17, 2003 10:29 PMFirst, I deploy my J2EEServerRemote ejb successfully.
Then I make a client java file to test that ejb and I also add that ejb obeserver-ejb.jar to CALSSPATH.The test file as follow:
import java.util.Hashtable;
import javax.ejb.CreateException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import org.obe.client.api.rmi.J2EEServerRemote;
import org.obe.client.api.rmi.J2EEServerRemoteHome;
/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class Test {
public static void main(String[] args){
Hashtable h = new Hashtable();
final J2EEServerRemote client;
h.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
h.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
h.put(Context.PROVIDER_URL, "jnp://localhost:1099");
h.put(Context.SECURITY_PRINCIPAL, "sa");
h.put(Context.SECURITY_CREDENTIALS, "sa");
try {
Context ctx = new InitialContext(h);
Object obj = ctx.lookup(J2EEServerRemoteHome.JNDI_NAME);
J2EEServerRemoteHome home = (J2EEServerRemoteHome)
PortableRemoteObject.narrow(obj,
J2EEServerRemoteHome.class);
System.out.println("begin");
client = home.create();
System.out.println("end");
} catch (NamingException e) {
System.out.println("error");
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Then I got an error just like follow:
error
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:652)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.(InitialContext.java:195)
at com.Test.main(Test.java:46)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
... 4 more
So who can tell me what I should do to solve this problem? Thank you very much!