Having trouble with DataSource in Tomcat 4.0.4

Discussions

Web tier: servlets, JSP, Web frameworks: Having trouble with DataSource in Tomcat 4.0.4

  1. Having trouble with DataSource in Tomcat 4.0.4 (1 messages)

    Here is my server.xml entry (with substitutions):

    <DefaultContext>
    <Resource name="jdbc/sybase" auth="Container" type="javax.sql.DataSource" />
    <ResourceParams name="jdbc/sybase">
    <parameter>
    <name>user</name>
    <value>username</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>qwerty</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>com.sybase.jdbc2.jdbc.SybDriver</value>
    </parameter>
    <parameter>
    <name>driverName</name>
    <value>jdbc:sybase:Tds:host:port/db</value>
    </parameter>
    </ResourceParams>
    </DefaultContext>

    Here is the JSP scriplet I am using to test it:

    <%
    try {
    Context ctx = new InitialContext();
    Context envCtx = (Context) ctx.lookup("java:comp/env");
    DataSource ds = (DataSource)envCtx.lookup("jdbc/sybase");
    Connection con = ds.getConnection();
    con.close();
    } catch(Exception ex) {
        out.println(ex); // print exception
    }
    %>

    When I execute this page, I get this:
    javax.naming.NamingException: Exception creating DataSource: tyrex/jdbc/xa/EnabledDataSource

    In my Tomcat console I get a stack trace that starts with:

    TyrexDataSourceFactory: Cannot create DataSource, Exception
    java.lang.NoClassDefFoundError: tyrex/jdbc/xa/EnabledDataSource

    Any ideas? :p
  2. Put your JDBC driver in your classpath. That might work !