Women in Technology

Hear us Roar

  Creating a Web Application with Ant and Tomcat 4
Subject:   Name jdbc is not bound in this Context
Date:   2003-01-26 14:40:00
From:   anonymous2
I am getting this error in my log file. I built the app from Ant with no problems. Do I need to reference the context.xml in the web.xml?

This is the full error:

2003-01-26 16:29:33 Couldn't create addressesDB sttribute: Couldn't open connection to Public database: Name jdbc is not bound in this Context

I also get this error that may be related.
2003-01-26 16:11:24 StandardContext[/AddressBook]: Exception sending context destroyed event to listener instance of class AddressBook.ContextListener
at AddressBook.ContextListener.contextDestroyed(Unknown Source)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3309)
at org.apache.catalina.core.StandardContext.stop(StandardContext.java:3697)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1036)
at org.apache.catalina.core.StandardHostDeployer.remove(StandardHostDeployer.java:420)
at org.apache.catalina.core.StandardHost.remove(StandardHost.java:852)
at org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:919)
at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:899)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:370)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:166)
at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1221)
at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1233)
at org.apache.catalina.core.StandardService.stop(StandardService.java:554)
at org.apache.catalina.core.StandardServer.stop(StandardServer.java:2224)
at org.apache.catalina.startup.Catalina.start(Catalina.java:543)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Name jdbc is not bound in this Context
    2003-01-27 13:51:17  anonymous2 [View]


    If you have not put your database's JDBC driver file in Tomcat's common/lib directory, as instructed, you get the message "Couldn't create addressesDB sttribute: Couldn't open connection to Public database: Cannot load JDBC driver class 'org.gjt.mm.mysql.Driver'". So I don't think this is your problem, but please check it anyway.

    Otherwise, you can view your Tomcat configuration by pointing your browser at http://localhost:8080/admin and looking at AddressBook's Context and Data Source Panels [see figures 8 & 9]. Do these panels look correct?

    You do not need to reference the context.xml in the web.xml. The information in context.xml gets put in Tomcat's conf/server.xml file automatically by the Ant/Tomcat admin process. Check server.xml out with your favourite text editor. Does this look correct?

    Finally, what versions of OS, MySQL, JDBC driver, Tomcat and Ant are you using?

    • Name jdbc is not bound in this Context
      2003-10-29 17:05:35  anonymous2 [View]

      I've met same problem when I use 'mysql 4.1 server", "mysql-connector-java-3.0.9-stable-bin.jar", and "tomcat 4.1.27 web server".

      Originally, I use JBuilder, mysql 4.1, tomcat 4.0 to test my pure 'servlets' web application and it works well.

      After, I move my web application into pure Tomcat 4.1.27 and compiled with ant. Though "ant compile" and "ant install" are ok, but the a method call from servlet to database connection always fails.

      The error message is "Couldn't open connection to database(in DBAgent): Name jdbc is not bound in this Context" in the db log file.

      Those displays on the screen are
      "HTTP Status 500 -


      type Exception report


      description The server encountered an internal error () that prevented it from fulfilling this request.




      I can see the correct context for dataresource in http://localhost:8080/admin.

      The lines I added to the server.xml are "
      <!-- Dragon Context -->
      <Context path="/dragon" docBase="dragon"
      debug="5" reloadable="true" crossContext="true">

      <Logger className="org.apache.catalina.logger.FileLogger"
      prefix="localhost_DBTest_log." suffix=".txt"

      <Resource name="jdbc/diary"
      <ResourceLink name="jdbc/diary"
      type="javax.sql.DataSource" />

      <ResourceParams name="jdbc/diary">
      <!-- Class name for mm.mysql JDBC driver -->

      <!-- The JDBC connection url for connecting to your MySQL dB.
      The autoReconnect=true argument to the url makes sure that the
      mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
      connection. mysqld by default closes idle connections after 8 hours.

      <!-- Maximum number of dB connections in pool. Make sure you
      configure your mysqld max_connections large enough to handle
      all of your db connections. Set to 0 for no limit.

      <!-- Maximum number of idle dB connections to retain in pool.
      Set to 0 for no limit.

      <!-- Maximum time to wait for a dB connection to become available
      in ms, in this example 10 seconds. An Exception is thrown if
      this timeout is exceeded. Set to -1 to wait indefinitely.

      <!-- MySQL dB username and password for dB connections -->

      Please help solve the problem.

      Thanks a lot.

      Julia Berlo