Hello all, I've been trying to follow along with the JNDI-datasource examples and seem to have gotten off track somewhere. I would greatly appreciate your having a look at this. Google searches on this topic have helped, but I'm still lost.
Running this dbtest.jsp doesn't generate anything in catalina.out or the localhost log. Reloading the page generates some local host entries, but nothing that looks like an error to me. The PostgreSQL log isn't complaining either. Thank you for considering the problem. Tom Sheehan Environment: RH 8.0, Kernel 2.4.18-14 on an i586 Sun JDK: Standard Edition (build 1.4.1_01-b01) no others installed $JAVA_HOME: /usr/java/j2sdk1.4.1_01 Tomcat: 4.1.18 full version, installed from binary, standalone $CATALINA_HOME: /usr/apache/jakarta-tomcat-4.1.18 PostgreSQL Version: 7.2.1 JDBC Driver: pgjdbc2.jar (shipped as binary with RH 8.0) The jdbc driver is only installed in: $CATALINA_HOME/common/lib My java class very closely models the sample from the documentation. The results of running dbtest.jsp clearly indicate the connection is not made: Foo -1 Bar Not Connected I wrote a seperate java class to run from the command line that runs the same query as the sample does. It returns the two rows I have in the table in question. So the database is configured properly to process jdbc requests from this same user. Here is what I understand is the relevant configuration info: The following is web.xml from /webapps/pgtest/WEB-INF -------------------------------------------------- <web-app> <description>PostgreSQL Test Application</description> <session-config> <session-timeout> 30 </session-timeout> </session-config> <resource-ref> <description>Test DB Connection</description> <res-ref-name>jdbc/pgTest</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </web-app> ---------------------------------------------------------- Connection code in the java class: /webapps/pgtest/WEB-INF/classes/foo/DBTest.class ( The .java code is there as well.) ---------------------------------------------------------------------------- ------------- package foo; import javax.naming.*; import javax.sql.*; import java.sql.*; public class DBTest { String foo = "Not Connected"; int bar = -1; public void init() { try{ Context ctx = new InitialContext(); if(ctx == null ) throw new Exception("Boom - No Context"); DataSource ds = (DataSource)ctx.lookup( "java:comp/env/jdbc/pgTest"); if (ds != null) { Connection conn = ds.getConnection(); etc... ----------------------------------------------------------------------- The following is extracted from $CATALINA_HOME/conf/server.xml ----------------------------------------------------------------------- <GlobalNamingResources> <Environment name="simpleValue" override="true" type="java.lang.Integer" value="30"/> <Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" scope="Shareable" type="org.apache.catalina.UserDatabase"/> <Resource name="jdbc/pgTest" scope="Shareable" type="javax.sql.DataSource"/> <ResourceParams name="UserDatabase"> <parameter> <name>factory</name> <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value> </parameter> <parameter> <name>pathname</name> <value>conf/tomcat-users.xml</value> </parameter> </ResourceParams> <ResourceParams name="jdbc/pgTest"> <parameter> <name>validationQuery</name> <value>SELECT * FROM qryTest</value> </parameter> <parameter> <name>url</name> <value>jdbc:postgresql://127.0.0.1:5432/db</value> </parameter> <parameter> <name>password</name> <value>pgsqlpassword</value> </parameter> <parameter> <name>maxActive</name> <value>4</value> </parameter> <parameter> <name>maxWait</name> <value>5000</value> </parameter> <parameter> <name>driverClassName</name> <value>org.postgresql.Driver</value> </parameter> <parameter> <name>username</name> <value>tomcat</value> </parameter> <parameter> <name>maxIdle</name> <value>2</value> </parameter> </ResourceParams> </GlobalNamingResources> --------------------------------------------------------------------- /webapps/pgtest/dbtest.jsp --------------------------------------------------------------------- <%@page contentType="text/html"%> <html> <head><title>PostgreSQL-Tomcat Test</title></head> <body> <%-- <jsp:useBean id="beanInstanceName" scope="session" class="package.class" /> --%> <%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%> <% foo.DBTest tst = new foo.DBTest(); tst.init(); %> <h2>Results</h2> Foo <%= tst.getId() %><br/> Bar <%= tst.getText() %> </body> </html> ---------------------------------------------------------------------------- ------------------- One of the things that makes me nervious is a lack of understanding of what's in common/lib. I may have gone too far throwing jar files at it. I replaced nothing that Tomcat installed, only added to it. Here's a listing: -rw-r--r-- 1 root root 45386 Dec 19 07:51 activation.jar -rw-r--r-- 1 root root 717666 Dec 19 07:51 ant.jar -rw-rw-rw- 1 root root 1180004 Feb 7 06:07 CastorXML-0.9.3.9.jar -rw-r--r-- 1 root root 90503 Dec 19 07:51 commons-collections.jar -rw-r--r-- 1 root root 62998 Dec 19 07:51 commons-dbcp.jar -rw-r--r-- 1 root root 18404 Dec 19 07:51 commons-logging-api.jar -rw-r--r-- 1 root root 28930 Dec 19 07:51 commons-pool.jar -rw-r--r-- 1 root root 182214 Dec 19 07:51 jasper-compiler.jar -rw-r--r-- 1 root root 69329 Dec 19 07:51 jasper-runtime.jar -rw-r--r-- 1 root root 84854 Dec 19 07:51 jdbc2_0-stdext.jar -rw-r--r-- 1 root root 98496 Dec 19 07:51 jndi.jar -rw-r--r-- 1 root root 8674 Dec 19 07:51 jta.jar -rw-rw-rw- 1 root root 325596 Feb 7 05:01 log4j-1.2.7.jar -rw-r--r-- 1 root root 280984 Dec 19 07:51 mail.jar -rw-r--r-- 1 root root 28496 Dec 19 07:51 naming-common.jar -rw-r--r-- 1 root root 18183 Dec 19 07:51 naming-factory.jar -rw-r--r-- 1 root root 38901 Dec 19 07:51 naming-resources.jar -rw-rw-rw- 1 root root 145751 Feb 7 05:46 ots-jts_1.0.jar -rw-r--r-- 1 root root 116204 Feb 5 08:43 pgjdbc2.jar -rw-r--r-- 1 root root 80054 Dec 19 07:51 servlet.jar -rw-rw-rw- 1 root root 240014 Feb 7 05:52 tyrex-1.0.jar -rw-rw-rw- 1 root root 885362 Jan 27 14:16 xercesImpl.jar -rw-rw-rw- 1 root root 124676 Jan 27 14:16 xml-apis.jar -rw-rw-rw- 1 root root 124676 Jan 27 14:16 xmlParserAPIs.jar --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]