Hi everybody,

I'm attempting to get the JNDI Datasource How To
example for Postgresql to work.

Here is the URL for the example:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html

After completing the listed steps the test.jsp error
page reports:
"java.sql.SQLException: No suitable driver"

Here are all my configuration steps, including the
files:
- On Fedora Core 3 - adduser postgres
- passwd postgres (set to postgres)
- chown postgres /var/lib/pqsql/data
- /usr/bin/initdb -D /var/lib/pgsql/data
- /usr/bin/postmaster -D /var/lib/pgsql/data >logfile
2>&1 &
- createdb test postgres
- psql test
create table testdata (id int not null primary key,
foo varchar(25), bar int);
insert into testdata values(1, 'hello', 12345);
- Update server.xml with this under the </Host> tag:
<Resource name="jdbc/postgres" auth="Container"
          type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
          url="jdbc:postgresql://127.0.0.1:5432/mydb"
          username="postgres" password="postgres"
maxActive="20" maxIdle="10" maxWait="-1"/>
</Context>
 cd /usr/local/jakarta-tomcat-5.5.7/common/lib
- wget
http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
- tar xzf jakarta-taglibs-20050303.tar.gz
- mkdir /var/www/webapps/dbtest
- vi /var/www/webapps/dbtest/test.jsp (I put the
example code here)
Here it is just in case:
        

<%@ 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/TestDB">
select id, foo, bar from testdata
</sql:query>

<html>
  <head>
    <title>DB Test</title>
  </head>
  <body>

  <h2>Results</h2>
  
<c:forEach var="row" items="${rs.rows}">
    Foo ${row.foo}<br/>
    Bar ${row.bar}<br/>
</c:forEach>

  </body>
</html>

- mkdir /var/www/webapps/dbtest/WEB-INF/
- vi /var/www/webapps/dbtest/WEB-INF/web.xml

I have the following in web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
   
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
    version="2.4">
  <description>Postgre Test App</description>
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/test</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
</web-app>

I now copy the necessary tag libraries over to the
application directory:
- mkdir /var/www/webapps/dbtest/WEB-INF/lib
- cp
/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/lib/jstl.jar
standard.jar /var/www/webapps/dbtest/WEB-INF/lib
- cp
/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/tld/*
/var/www/webapps/dbtest/WEB-INF

- catalina.sh run
- http://localhost:8080/dbtest/test.jsp
- And the console gives the following:

[EMAIL PROTECTED] local]# catalina.sh run
Using CATALINA_BASE:   /usr/local/jakarta-tomcat-5.5.7
Using CATALINA_HOME:   /usr/local/jakarta-tomcat-5.5.7
Using CATALINA_TMPDIR:
/usr/local/jakarta-tomcat-5.5.7/temp
Using JRE_HOME:       /usr/java/jdk1.5.0
Mar 3, 2005 10:22:45 PM
org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Mar 3, 2005 10:22:45 PM
org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1106 ms
Mar 3, 2005 10:22:45 PM
org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Mar 3, 2005 10:22:45 PM
org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
Mar 3, 2005 10:22:45 PM
org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Mar 3, 2005 10:22:46 PM
org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 3, 2005 10:22:46 PM
org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Mar 3, 2005 10:22:46 PM org.apache.jk.server.JkMain
start
INFO: Jk running ID=0 time=0/142  config=null
Mar 3, 2005 10:22:47 PM
org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath
resource
Mar 3, 2005 10:22:47 PM
org.apache.catalina.startup.Catalina start
INFO: Server startup in 1701 ms
Mar 3, 2005 10:23:29 PM
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw
exception
javax.servlet.jsp.JspException: Unable to get
connection, DataSource invalid:
"java.sql.SQLException: No suitable driver"
        at
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(Unknown
Source)
        at
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(Unknown
Source)
        at
org.apache.jsp.test_jsp._jspx_meth_sql_query_0(org.apache.jsp.test_jsp:101)
        at
org.apache.jsp.test_jsp._jspService(org.apache.jsp.test_jsp:58)
        at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
        at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
        at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
        at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
        at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)




Has anyone experiences/fixed this?

Thanks in advance for your help!

- Ole


 


        
                
__________________________________ 
Celebrate Yahoo!'s 10th Birthday! 
Yahoo! Netrospective: 100 Moments of the Web 
http://birthday.yahoo.com/netrospective/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to