透過jbuilder打包的app在控制檯執行訪問jboss的ejb出現javax.naming.NoInitialContextException

一線陽光發表於2004-06-03
我打包成exe檔案,然後啟動jboss,訪問釋出在jboss上的ejb,但上下文環境總出現以下錯誤:
javax.naming.NoInitialContextException: Need to specify class name in environment or system pro
perty, or as an applet parameter, or in an application resource file: java.naming.factory.init
ial

我程式中設定上下文環境是這樣的:
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
String PROVIDER_URL = "jnp://192.168.70.79:1099";
environment.put(Context.PROVIDER_URL, PROVIDER_URL);
return new InitialContext(environment);
然後把jboss的jboss-j2ee.jar和jnp-client.jar全打進和exe檔案對應的jar裡了,即使把jnp-client.jar設定到classpath也出同樣的錯 :(

相關文章