javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context

后端 未结 5 1753
醉梦人生
醉梦人生 2020-12-21 00:50

I\'m developing a spring application which uses tomcat server managed connection pool.

I defined datasource in tag in context.xml of tomcat: (i am using spring 2.0.

相关标签:
5条回答
  • 2020-12-21 01:07

    That will in case of Tomcat happen when you have for some reason dropped arbitrary servletcontainer-specific JARs such as jsp-api.jar, servlet-api.jar, catalina.jar, etc in webapp's /WEB-INF/lib. You should remove all servletcontainer-specific JARs from there, they do not belong there.

    0 讨论(0)
  • 2020-12-21 01:15

    I faced similar problem with tomcat and did the following in eclipse to solve it:

    1. In the server's context.xml, included the jdbc connection details.
    2. Stop the server
    3. Clean the project(Project --> Clean) , the tomcat server (Server--> Right Click --> Clean) and Tomcat work directory (Server--> Right Click--> Clean Tomcat Work Directory).
    4. Start the server and run.

    Even after maintaining the details in context.xml, sometimes it might not get reflected. In such cases follow step#3 and hope it helps.

    0 讨论(0)
  • 2020-12-21 01:26

    In Eclipse: make sure you have the right context.xml file. This especially valid when you have installed multiple servers.

    In your Servers tab -> Right click on your deployed web module -> Browse Deployment Location -> ../conf/context.xml. Make sure this is the file you want to be using.

    I hope this saves you some time, as I wasted some time on it.

    0 讨论(0)
  • 2020-12-21 01:31

    Please update your web.xml with the something similar to the following tag

    <resource-env-ref>
      <description>DataSource
      </description>
      <resource-env-ref-name>
        dbc/irb_prod
      </resource-env-ref-name>
      <resource-env-ref-type>
        javax.sql.DataSource
      </resource-env-ref-type>
    </resource-env-ref>
    

    You need to refer this link too for more information

    0 讨论(0)
  • 2020-12-21 01:31

    In my case it seems that I had to first close my file explorer (FreeCommander XE) and then do the eclipse cleans (project and server), make sure to close any other programs that might have handles to deployed files even if the files are not open in those programs anymore

    0 讨论(0)
提交回复
热议问题