Re: [LONG]Tomcat jdbc connection pb

From: Gluon (No.Spam_at_cnil.fr)
Date: 08/16/04

  • Next message: Andy Flowers: "Re: Resultset from Java Stored Procedure"
    Date: Mon, 16 Aug 2004 14:56:05 +0200
    
    

    OK, i found the pb, tricky declaration of web-app tag in web.xml

    but that does not solve the hibernate issue :(

    Gluon wrote:

    > Hy,
    > i'm newbie with Tomcat and i tried to use Hibernate to build some demo
    > app. As it fails with the jdbc connection, i move for a more basic
    > example from jakarta:
    >
    > Can someone help with this?
    >
    > Here is the various files:
    >
    > my webapp is called hibernate:
    > webapps\hibernate\WEB-INF\web.xml:
    > <?xml version="1.0" encoding="ISO-8859-1"?>
    >
    > <!DOCTYPE web-app
    > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    > "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    >
    > <web-app>
    > <display-name>Struts with Hibernate</display-name>
    >
    > <!-- Standard Action Servlet Configuration (with debugging) -->
    > <servlet>
    > <servlet-name>action</servlet-name>
    > <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    > <init-param>
    > <param-name>config</param-name>
    > <param-value>/WEB-INF/struts-config.xml</param-value>
    > </init-param>
    > <init-param>
    > <param-name>debug</param-name>
    > <param-value>2</param-value>
    > </init-param>
    > <init-param>
    > <param-name>detail</param-name>
    > <param-value>2</param-value>
    > </init-param>
    > <load-on-startup>2</load-on-startup>
    > </servlet>
    >
    >
    > <!-- Standard Action Servlet Mapping -->
    > <servlet-mapping>
    > <servlet-name>action</servlet-name>
    > <url-pattern>*.do</url-pattern>
    > </servlet-mapping>
    >
    >
    > <!-- The Usual Welcome File List -->
    > <welcome-file-list>
    > <welcome-file>index.jsp</welcome-file>
    > </welcome-file-list>
    >
    >
    > <!-- Struts Tag Library Descriptors -->
    > <taglib>
    > <taglib-uri>/tags/struts-bean</taglib-uri>
    > <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    > </taglib>
    >
    > <taglib>
    > <taglib-uri>/tags/struts-html</taglib-uri>
    > <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    > </taglib>
    >
    > <taglib>
    > <taglib-uri>/tags/struts-logic</taglib-uri>
    > <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    > </taglib>
    >
    > <taglib>
    > <taglib-uri>/tags/struts-nested</taglib-uri>
    > <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
    > </taglib>
    >
    > <taglib>
    > <taglib-uri>/tags/struts-tiles</taglib-uri>
    > <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
    > </taglib>
    >
    > <!-- -->
    > <resource-ref>
    > <description>DB Connection</description>
    > <res-ref-name>jdbc/hibernate</res-ref-name>
    > <res-type>javax.sql.DataSource</res-type>
    > <res-auth>Container</res-auth>
    > </resource-ref>
    >
    > </web-app>
    >
    > Here is the Tomcat 5.0\conf\Catalina\localhost\Hibernate.xml
    > <?xml version='1.0' encoding='utf-8'?>
    > <Context displayName="Struts with Hibernate" docBase="hibernate"
    > path="/Hibernate" reloadable="true" workDir="D:\Program Files\Apache
    > Software Foundation\Tomcat 5.0\webapps\hibernate\work">
    > <Logger className="org.apache.catalina.logger.FileLogger"
    > prefix="hibernateWebApp." timestamp="true" verbosity="0"/>
    > <Manager className="org.apache.catalina.session.StandardManager"
    > maxActiveSessions="4" maxInactiveInterval="1800">
    > </Manager>
    > <Resource name="jdbc/hibernate" type="javax.sql.DataSource"/>
    > <ResourceParams name="jdbc/hibernate">
    > <parameter>
    > <name>factory</name>
    > <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    > </parameter>
    > <parameter>
    > <name>validationQuery</name>
    > <value>select id from item;</value>
    > </parameter>
    > <parameter>
    > <name>url</name>
    > <value>jdbc:mysql://localhost:3306/test?autoReconnect=true</value>
    > </parameter>
    > <parameter>
    > <name>password</name>
    > <value>testuser</value>
    > </parameter>
    > <parameter>
    > <name>maxActive</name>
    > <value>10</value>
    > </parameter>
    > <parameter>
    > <name>maxWait</name>
    > <value>1000</value>
    > </parameter>
    > <parameter>
    > <name>driverClassName</name>
    > <value>com.mysql.jdbc.Driver</value>
    > </parameter>
    > <parameter>
    > <name>username</name>
    > <value>testuser</value>
    > </parameter>
    > <parameter>
    > <name>maxIdle</name>
    > <value>30</value>
    > </parameter>
    > </ResourceParams>
    > </Context>
    >
    >
    > and now the jsp webapps\hibernate\pages\Test.jsp:
    > <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
    > <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    >
    > <sql:query var="rs" dataSource="jdbc/hibernate">
    > select * from item
    > </sql:query>
    >
    > <html>
    > <head>
    > <title>DB Test</title>
    > </head>
    > <body>
    >
    > <h2>Results</h2>
    >
    > <c:forEach var="row" items="${rs.rows}">
    > ID ${row.id}<br/>
    > NAME ${row.name}<br/>
    > DESCRIPTION ${row.description}<br/>
    > </c:forEach>
    >
    > </body>
    > </html>
    >
    >
    > the mySQL connection works fine:
    > C:\mysql\bin>mysql test -utestuser -ptestuser
    > Welcome to the MySQL monitor. Commands end with ; or \g.
    > Your MySQL connection id is 2 to server version: 4.0.20a-nt-max
    >
    > Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    >
    > mysql> show tables;
    > +----------------+
    > | Tables_in_test |
    > +----------------+
    > | item |
    > +----------------+
    > 1 row in set (0.05 sec)
    >
    > mysql> show columns in item;
    > +-------------+-------------+------+-----+---------+----------------+
    > | Field | Type | Null | Key | Default | Extra |
    > +-------------+-------------+------+-----+---------+----------------+
    > | id | bigint(11) | | PRI | NULL | auto_increment |
    > | name | varchar(32) | | | | |
    > | description | longtext | YES | | NULL | |
    > +-------------+-------------+------+-----+---------+----------------+
    > 3 rows in set (0.05 sec)
    >
    > but the servelt raise the following exception:
    >
    > javax.servlet.ServletException: Unable to get connection, DataSource
    > invalid: "org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC
    > driver of class '' for connect URL 'null'"
    > org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
    >
    > org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    >
    > org.apache.jsp.pages.Test_jsp._jspService(Test_jsp.java:81)
    > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    > javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
    >
    > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    >
    > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    > javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    >
    > cause mère
    >
    > javax.servlet.jsp.JspException: Unable to get connection, DataSource
    > invalid: "org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC
    > driver of class '' for connect URL 'null'"
    > org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:276)
    >
    > org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159)
    >
    > org.apache.jsp.pages.Test_jsp._jspx_meth_sql_query_0(Test_jsp.java:100)
    > org.apache.jsp.pages.Test_jsp._jspService(Test_jsp.java:58)
    > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    > javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
    >
    > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    >
    > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    > javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    >
    >
    >


  • Next message: Andy Flowers: "Re: Resultset from Java Stored Procedure"

    Relevant Pages

    • Re: Ingres JDBC driver hangs on getting a connection
      ... that with this connection pooling the tests ran ... no more activity neither at the Java process nor at the Ingres ... after reporting idle client connections which it was aborting, ... the Hibernate test suite continued to run! ...
      (comp.databases.ingres)
    • Re: Ingres JDBC driver hangs on getting a connection
      ... here are the best settings so far or running the test suite. ... because you didn't know whether Hibernate ... Ingres doesn't support reverse scrolling cursors and cursor type ... best would be disabling the connection test. ...
      (comp.databases.ingres)
    • Re: Ingres JDBC driver hangs on getting a connection
      ... with your tips for the configuration of Hibernate and Ingres I finally ... succeeded running the complete Hibernate Junit test suite (excluding ... The Ingres error log stated some errors like this: ... best would be disabling the connection test. ...
      (comp.databases.ingres)
    • Hibernate, JBoss 4, MySQL5 Problem
      ... und Hibernate zu realisieren. ... WARN [LocalManagedConnectionFactory] Destroying connection that is not ... object is not an instance of declaring class ...
      (de.comp.lang.java)
    • Re: Ingres JDBC driver hangs on getting a connection
      ... here are the best settings so far or running the test suite. ... because you didn't know whether Hibernate ... Ingres doesn't support reverse scrolling cursors and cursor type ... best would be disabling the connection test. ...
      (comp.databases.ingres)