感谢jman的回复,现在我使用jboss3.22,但是还不行。 我的目录结构如下: org ---jboss --------example ---------------classesresources ---jndi.properties 在jndi.properties中,我照前面写了。运行的时候出现异常如下: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource 我觉得疑惑的是:org.jnp.interfaces.NamingContextFactory 是在哪个包里?从哪里下载?下载后还要设置些什么?(不然程序怎么知道从哪里找?)恳请各位指教,这个问题困扰我多时了。
如果你调用ejb的客户端和你的ejb容器在同一个电脑上,比如,你用sun的appserver,来执行客户端和ejb,
那你其实不需要特别去初始化context的。
你只需:
Context ctx = new InitialContext();
就可以了。
Context.INITIAL_CONTEXT_FACTORY
"com.ibm.websphere.naming.WsnInitialContextFactory "
Context.PROVIDER_URL
"iiop://localhost:900 " WAS5:
Context.INITIAL_CONTEXT_FACTORY
"com.ibm.websphere.naming.WsnInitialContextFactory "
Context.PROVIDER_URL
"iiop://localhost:2809 "
------------------------------------------
environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
environment.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2809");
environment.put(Context.URL_PKG_PREFIXES, "com.ibm.ws.naming");
------------------------------------------------------------------------------------------------------------------Weblogic:
Context.INITIAL_CONTEXT_FACTORY
"weblogic.jndi.WLInitialContextFactory "
Context.PROVIDER_URL
"t3://127.0.0.1:7001 "
J2EE SDK(J2EE RI):
Context.INITIAL_CONTEXT_FACTORY
"com.sun.jndi.cosnaming.CNCtxFactory "
Context.PROVIDER_URL
"iiop://127.0.0.1:1050 "
SilverStream:
Context.INITIAL_CONTEXT_FACTORY
"com.sssw.rt.jndi.AgInitCtxFactory "
Context.PROVIDER_URL
"sssw://localhost:80 "
OC4J
Context.INITIAL_CONTEXT_FACTORY
"com.evermind.server.rmi.RMIInitialContextFactory"
Context.PROVIDER_URL
"ormi://127.0.0.1/"
JBOSS的:
java.naming.factory.initial
"org.jnp.interfaces.NamingContextFactory"
java.naming.provider.url
"localhost:1099"
我的目录结构如下:
org
---jboss
--------example
---------------classesresources
---jndi.properties
在jndi.properties中,我照前面写了。运行的时候出现异常如下:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource 我觉得疑惑的是:org.jnp.interfaces.NamingContextFactory 是在哪个包里?从哪里下载?下载后还要设置些什么?(不然程序怎么知道从哪里找?)恳请各位指教,这个问题困扰我多时了。