Database connection problem (Struts)

Discussions

Web tier: servlets, JSP, Web frameworks: Database connection problem (Struts)

  1. Database connection problem (Struts) (5 messages)

    Hello all,

    i rtfm, stfw but have this problem unsolved.
    I configured my <datasource> Tag:

    <data-sources>
    <data-source type="org.apache.commons.dbcp.BasicDataSource">
    <set-property
    property="driverClassName"
    value="oracle.jdbc.driver.OracleDriver" />
    <set-property
    property="url"
    value="jdbc:oracle:thin:@host:1521:datbase" />
    <set-property
    property="username"
    value="me" />
    <set-property
    property="password"
    value="xxxxx" />
    <set-property
    property="maxActive"
    value="10" />
    <set-property
    property="maxWait"
    value="5000" />
    <set-property
    property="defaultAutoCommit"
    value="false" />
    <set-property
    property="defaultReadOnly"
    value="false" />
    <set-property
    property="validationQuery"
    value="SELECT COUNT(*) FROM t_config" />
    </data-source>
    </data-sources>

    When I start my server, the following error appears on the browser:
    [root cause]
    java.lang.NoClassDefFoundError: org/apache/struts/legacy/GenericDataSource
    ...

    I don't understand this... am i not using the dbcp?
    The commons-dbcp.jar is in my classpath, of course.
    Maybe you could give me some hint to solve this.

    Thank you!
    Chris

    BTW: I use Struts 1.1 RC2 and Tomcat 4.1.12
  2. Place commons-dbcp.jar in the corresponding web app lib directory i.e. C:\jakarta-tomcat\webapps\YOUR_APP\WEB-INF\lib

    Kalin
  3. There is a jar file called struts-legacy.jar that contains the GenericDataSource and GenericConnection classes. Not sure how long this jar has been included in the distribution, but I just downloaded the 1.1 release and it's there. You need to get this jar and put it in the WEB-INF\lib directory.

    Chuck Cavaness
    Author of Programming Jakarta Struts by O'Reilly
  4. Thanks Kalin, but this was not the problem.
    Chuck was right, the struts-legacy.jar was not copied in my webapp/lib!
    Thank you for this tip!

    Regards,
    Chris


    BTW: Progamming Jakarta Struts is welldone! Congrats on that @chuck
  5. If you're hosting on 9iAS as well as using Oracle for a db, I've found that iAS is much happier using a JNDI source.

    It will look something like:

    <data-sources>
    <data-source name="bcsatDS"
         class="oracle.jdbc.pool.OracleConnectionPoolDataSource"
         username="[username]"
         password="[password]"
         url="jdbc:oracle:thin:@[your db]"
         connection-driver="oracle.jdbc.driver.OracleDriver"
         location="jdbc/[location]" xa-location="jdbc/xa/[location]"
         ejb-location="jdbc/[location]"
         connection-retry-interval="5"
         max-connect-attempts="3"
         inactivity-timeout="120"
         max-connections="400"
         min-connections="20"
         wait-timeout="120"/>
    </data-sources>

    Hope that helps.
  6. Problem persistes[ Go to top ]

    Hello all,

    >
    > i rtfm, stfw but have this problem unsolved.
    > I configured my <datasource> Tag:
    >
    > <data-sources>
    > <data-source type="org.apache.commons.dbcp.BasicDataSource">
    > <set-property
    > property="driverClassName"
    > value="oracle.jdbc.driver.OracleDriver" />
    > <set-property
    > property="url"
    > value="jdbc:oracle:thin:@host:1521:datbase" />
    > <set-property
    > property="username"
    > value="me" />
    > <set-property
    > property="password"
    > value="xxxxx" />
    > <set-property
    > property="maxActive"
    > value="10" />
    > <set-property
    > property="maxWait"
    > value="5000" />
    > <set-property
    > property="defaultAutoCommit"
    > value="false" />
    > <set-property
    > property="defaultReadOnly"
    > value="false" />
    > <set-property
    > property="validationQuery"
    > value="SELECT COUNT(*) FROM t_config" />
    > </data-source>
    > </data-sources>
    >
    > When I start my server, the following error appears on the browser:
    > [root cause]
    > java.lang.NoClassDefFoundError: org/apache/struts/legacy/GenericDataSource
    > ...
    >
    > I don't understand this... am i not using the dbcp?
    > The commons-dbcp.jar is in my classpath, of course.
    > Maybe you could give me some hint to solve this.
    >
    > Thank you!
    > Chris
    >
    > BTW: I use Struts 1.1 RC2 and Tomcat 4.1.12