javax.naming.NameNotFoundException: Name jdbc is not bound in this Context 在tomcat中發布web項目,可能是因為spring中配置了jndi(只配置了jndi,其他的有工具包封裝了)。
啟動的時候報錯(在項目目錄下,在tomcat中配置context指向項目目錄就沒問題,打包發布到
tomcat就報錯了),拋的異常是:
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
在web.xml中添加配置如下:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
=================================== Name java:comp is not bound in this Context
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
--這是在初始化context時(Context envCtx = (Context) ctx.lookup("java:comp/env");)拋出的異常;解決方案是把工程/WEB-INF/lib下面naming- common.jar,naming-factory.jar,naming-resources.jar三個jar包刪除;
http://hi.baidu.com/salala1/blog/item/c9e6f3ed7d2a9d4778f05510.html
===================================
第一種沒解決;
第二種應該是tomcat/common/lib下的檔案和WEB-INF/lib下的檔案衝突造成的。解決問題