读书人

Tomcat5使用JNDI在javabean出现javax.

发布时间: 2014-01-26 14:34:54 作者: rapoo

异常信息:
javax.naming.NoInitialContextException:
Need to specify class name in environment or system property,
or as an applet parameter, or in an application resource file:
java.naming.factory.initial

是环境没配置对?JNDI和web.xml都配置了啊

------解决方法--------------------------------------------------------
参见:
http://blog.csdn.net/kingapex1/archive/2004/07/15/42050.aspx
------解决方法--------------------------------------------------------
应该是初始化方法:

1种 用参数,如:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
....
Context ctx = new InitialContext(env);

2 用配置文件,缺省jndi.properties。(好像新规范要用xml,我不确定),如:
Context.INITIAL_CONTEXT_FACTORY="com.sun.jndi.fscontext.RefFSContextFactory"


        

读书人网 >Java Exception

热点推荐