因为 JBoss的各个版本的差异,编写EJB时还是会出现些差错的,这里做下笔记 jboss-5.1.0.GA环境下
jboss-5.1.0.GA启动时一点bug解决方案:http://blog.csdn.net/u013330391/article/details/46375387
1、编写 Client时 将jboss client目录下的jar加到类路径下 ;
2、在类路径下 新建 jndi.properties 文件
内容如下:
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
或者
private static Context getJBossInitialContext() {
final String INIT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
final String SERVER_URL = "localhost:1099";
Context ctx = null;
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, INIT_FACTORY);
props.put(Context.PROVIDER_URL, SERVER_URL);
try {
ctx = new InitialContext(props);
} catch (NamingException e) {
e.printStackTrace();
}
return ctx;
}
3、JNDI查找时 出 Exception in thread "main" java.lang.ClassCastException: org.jnp.interfaces.Naming
http://blog.sina.com.cn/s/blog_758f25da0100t3qm.html