Name java:comp is not bound in this Context

來源:互聯網
上載者:User
  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下的檔案衝突造成的。解決問題

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.