今天在调试时,突然发现数据连接池不能用了,但我用jsp文件测试,是ok了,于是我在类文件中添加main进行测试,也出现了错误,一直想不明白,后来经过一位朋友的提醒,原来犯了一个低级错误:java单元的环境是jdk;而jsp的环境却是tomcat;数据连接池是在tomcat中配置的,所以能正常运行的,但java测试的环境只有jdk,所以在引用数据连接池时就时出现找不环境的错误~
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
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
connect fail at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.zb.struts.db.Db.getDbConn(Db.java:37)
at com.zb.struts.db.Db.getStm(Db.java:52)
at com.zb.test.TestExcel.readDataToExcel3(TestExcel.java:239)
at com.zb.test.TestExcel.main(TestExcel.java:50
JSP应用中JDK和TOMCAT环境的问题
最新推荐文章于 2021-06-20 21:08:27 发布