Struts/MySQL/Tomcat error - Unavailable Exception

Discussions

Web tier: servlets, JSP, Web frameworks: Struts/MySQL/Tomcat error - Unavailable Exception

  1. Struts/MySQL/Tomcat error - Unavailable Exception (2 messages)

    Hello Everyone-

    I am having a problem which seems to be very common, in that I have seen several posts on different forums describing the same thing, all of them without replies. The problem that I am having is this:

    I am using Struts, and I describe a MySQL datasource in my struts-config.xml file:


      <data-sources>
        <data-source key="AQUAINT" type="org.apache.commons.dbcp.BasicDataSource">
          <set-property property="description" value="AQUAINT Sample Data"/>
          <set-property property="driverClassName" value="com.mysql.jdbc.Driver"/>
          <set-property property="user" value="username"/>
          <set-property property="password" value="password"/>
          <set-property property="url" value="jdbc:mysql://flake.cs.uiuc.edu/mirror"/>
          <set-property property="auto-commit" value="false"/>
        </data-source>
      </data-sources>


    All of this looks fine and good to me. I deploy the .war file to Tomcat (version 5), and get an error. Here is the first few lines of the rediculously long stacktrace:

    005-02-23 13:43:30 StandardContext[/iTrack]Marking servlet iTrack as unavailable
    2005-02-23 13:43:30 StandardContext[/iTrack]Servlet /iTrack threw load() exception
    javax.servlet.UnavailableException: Initializing application data source AQUAINT
        at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:782)
        at org.apache.struts.action.ActionServlet.init(ActionServlet.java:331)
        at org.ccg.itrack.struts.framework.ITrackActionServlet.init(ITrackActionServlet.java:37)
        at javax.servlet.GenericServlet.init(GenericServlet.java:211)

    I have made sure the user and password combination are correct, and can successfully connect to the database using the command-line mysql client. I have also made sure that the commons-dbcp and required jars are in the correct places and that the mysql driver (com.mysql.jdbc.Driver) is correctly installed (in my WEB-INF/lib directory).

    Has anyone actually managed to FIX this problem? Is there something that I'm missing? A possible version conflict? Compatability issues between org.apache.commons.dbcp.BasicDataSource and com.mysql.jdbc.Driver? Any help would be GREATLY appreciated. Thanks,

    P
  2. I managed to get this working, but not using struts. What I do is create a JDBC DataSource in Tomcat, and make it available to my application via JNDI. What sparse coverage I have seen of these issues seems to indicate that this is the de facto way to handle this.
  3. Hi,

    You can visit http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml

    This tutorial is all about configuring Struts Datasource On Tomcat 5.5.9.

    Regards