Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id F39EBBBDD52 for ; Fri, 18 Nov 2011 10:38:50 -0400 (AST) Received: from mail-yx0-f174.google.com ([209.85.213.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RRPad-0001MK-13 for pgsql-jdbc@postgresql.org; Fri, 18 Nov 2011 14:38:51 +0000 Received: by yenq3 with SMTP id q3so2521503yen.19 for ; Fri, 18 Nov 2011 06:38:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=54SqCD29DV5a+hGUi4wO2dcZ8UihO9J+hnKnOY3xZVs=; b=lSlgEzk8K3XKC1irvcEstCnI1PtmWGeMzUNmrpDHrZxjd1KuBDQZE1M+WOQ8tpCA4C IjKkFL/PCkXWuGv/iu8zZ0kMh6AtmRnO67xu9RsJhbFdPJMReYk23ykQ86zcSSFX1u66 6aCcQsCnl+YDAtA1piuHOFtshMtKIS81ZimfI= Received: by 10.236.147.114 with SMTP id s78mr5328002yhj.45.1321627118597; Fri, 18 Nov 2011 06:38:38 -0800 (PST) Received: from [10.17.10.34] (office.vivisimo.com. [206.210.75.84]) by mx.google.com with ESMTPS id u19sm2571272ank.11.2011.11.18.06.38.37 (version=SSLv3 cipher=OTHER); Fri, 18 Nov 2011 06:38:37 -0800 (PST) Message-ID: <4EC66DEC.70200@acm.org> Date: Fri, 18 Nov 2011 09:38:36 -0500 From: Bruce Adams User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Tomcat7 connection pool with postgresql References: <201111181109.28089.achill@matrix.gatewaynet.com> In-Reply-To: <201111181109.28089.achill@matrix.gatewaynet.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 201111/53 X-Sequence-Number: 22388 Achilleas - You need to put something in Tomcat's context.xml. Usually, the Resource goes in context.xml, not in server.xml. Can you try simply moving your existing Resource from server.xml to context.xml? If you really need to put the Resource in server.xml, I think you also need a ResourceLink in context.xml to make it available to web applications. - Bruce On 11/18/2011 04:09 AM, Achilleas Mantzios wrote: > Hello, > although i have been a jboss/postgresql admin/dba for ages, it seems that i am stuck with tomcat. > i am trying in tomcat7 to set a connection pool'ed data source with postgresql. > i was following the tomcat7 docs here : > http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#PostgreSQL > > My server.xml portion looks as follows : > > ... > driverClassName="org.postgresql.Driver" > maxActive="20" maxIdle="10" maxWait="-1" > name="jdbc/postgres" > username="springuser" password="springuser" > type="javax.sql.DataSource" > url="jdbc:postgresql://localhost/sia"/> > > > my app's web.xml resource-ref goes as follows : > > postgreSQL Datasource sia > jdbc/postgres > javax.sql.DataSource > Container > > > in my .jsp this code fails (ommiting boilerplate) > > InitialContext ic = new InitialContext(); > DataSource ds = (DataSource) ic.lookup( "java:/comp/env/jdbc/postgres" ); > Connection con=null; > try { > con = ds.getConnection(); > con.setAutoCommit(true); > } > catch () {...} > finally {...} > > with : > > org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' > org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452) > org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) > org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) > org.apache.jsp.index_jsp._jspService(index_jsp.java:102) > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) > javax.servlet.http.HttpServlet.service(HttpServlet.java:722) > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433) > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389) > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333) > javax.servlet.http.HttpServlet.service(HttpServlet.java:722) > > root cause > java.sql.SQLException: No suitable driver > java.sql.DriverManager.getDriver(DriverManager.java:279) > org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437) > org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) > org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) > org.apache.jsp.index_jsp._jspService(index_jsp.java:102) > > .... > > However if i do the classic standalone classloading : > Class.forName("org.postgresql.Driver"); > String url = "jdbc:postgresql://localhost/sia?user=springuser&password=springuser"; > con = DriverManager.getConnection(url); > it works ok. > > To be honest, i haven't done any extensive reading on those matters, besides the official tomcat docs, > but time constraints are far too restrictive. Thank you all for your time! > > PS users from the tomcat list, pls include my address since i am not subscribed in your list. >