Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E14DF6323D2 for ; Wed, 2 Jun 2010 23:19:54 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 07213-08 for ; Thu, 3 Jun 2010 02:19:45 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.4.227.11]) by mail.postgresql.org (Postfix) with ESMTP id 462C76323AE for ; Wed, 2 Jun 2010 23:19:46 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id 2DC167923D; Thu, 3 Jun 2010 10:19:42 +0800 (WST) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id CA3E0AF308; Thu, 3 Jun 2010 10:17:55 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id uEr1R4V5wZrs; Thu, 3 Jun 2010 10:17:50 +0800 (WST) Received: from [10.1.1.7] (124-148-251-30.dyn.iinet.net.au [124.148.251.30]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 4B1B5AF307; Thu, 3 Jun 2010 10:17:50 +0800 (WST) Message-ID: <4C071135.3020607@postnewspapers.com.au> Date: Thu, 03 Jun 2010 10:19:33 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: philfrei@aol.com CC: pgsql-jdbc@postgresql.org Subject: Re: jdbc works in java app, fails in servlet: "no suitable jdbc found" References: <8CCD02714A2791E-E2C-7A83@webmail-m042.sysops.aol.com> <4C05F409.7060805@postnewspapers.com.au> <8CCD0CAC9B7220C-D8C-4F1C@webmail-d098.sysops.aol.com> In-Reply-To: <8CCD0CAC9B7220C-D8C-4F1C@webmail-d098.sysops.aol.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-10 required=5 tests=BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/25 X-Sequence-Number: 20595 On 3/06/2010 8:28 AM, philfrei@aol.com wrote: > Thank you for the reply! > >> You need to preload the PostgreSQL driver... > > Being new to this, I find myself second-guessing words as simple as > "preload". The servlet "NearbyTest" has a constructor and a single > method "doGet" which is invoked by an HTML page. As the first working > statement in the "doGet" method (at this point everything else is > commented out), I tried using the recommended statements. Both of them > elicited the same error message: > > try { > // Class.forName("org.postgresql.Driver"); > this.getClass().getClassLoader().loadClass("org.postgresql.Driver"); > } catch (ClassNotFoundException e1) { > e1.printStackTrace(); > } > > java.lang.ClassNotFoundException: org.postgresql.Driver I'd say your classpath is misconfigured; the classloader cannot find PostgreSQL. On web service containers sometimes the dependencies for the servelet must all be embedded in a .war with the serverlet jar. Is that the case here? > Is there another stage (prior to the servlet's > "doGet") at which the "preloading" should occur? Nope, just loading the class is sufficient. > The stack trace indicates code that is part of Apache. Is there possibly > something that has to be configured in Apache that is missing? Well the trace refers to org.apache.catalina.loader.WebappClassLoader , which is a part of Apache Catalina. It has nothing to do with the Apache web server except that they're both from the Apache project. Catalina is Tomcat's servlet container. That further suggests that you need to configure your classpath in your web app environment, or have an issue with how your app and dependencies are packaged. I've only done this stuff with Maven & Netbeans targeting Glassfish, so I can't really offer much help with the details of doing it right using Eclipse's build system and a Tomcat target. -- Craig Ringer