标签:
曾经想尝试着写一下,失败,今天在jboss的EJB3论坛上有人问到同样的问题,解决方案如下:
Create a jndi.properties file, place it in the classpath (usually in the base directory of the jar file), with these contents:
| Code: |
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=localhost:1099 java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces |
Of course, replace locahost with your host name if you are attempting remote access.
或者采用HashMap:
Hashtable<String, String> props= new Hashtable<String, String>(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL,"jnp://localhost:1099" ); props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces" ); Context ctx = new InitialContext( props );
只不过对于依赖注入还没有更好的方案,等jboss的ejb3最新实现出来再看看


档案
日志
相册
视频



评论
想第一时间抢沙发么?