You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Paul McGovern <mc...@canuck.com> on 2002/08/18 02:12:57 UTC
BasicDataSourceFactory and TC 4.1.9
I am having probelms getting a Connection from the DataSource I get out of
JNDI. I set up the Resource section of my server.xml as described in the
HOW-TO for 4.1.9 and am using mm.mysql 2.0.14 with MySQL 3.23.51. The DB and
dirver seem to work fine together.
It seems I can get the DataSource from the JNDI context as expected, but
calling getConnection() yeilds an SQLException that says, "Cannot load JDBC
driver class 'null'". The driver is sitting in common/lib and can be seen and
used by servlets in my context if I do it 'by hand'. A quick look through
DBCP's BasicDataSourceFactory confirms 'driverClassName' is the correct
parameter name for the driver class, and the exception is being generated in
BasicDataSource:
// Load the JDBC driver class
Class driverClass = null;
try {
driverClass = Class.forName(driverClassName);
} catch (Throwable t) {
String message = "Cannot load JDBC driver class '" +
driverClassName + "'";
logWriter.println(message);
t.printStackTrace(logWriter);
throw new SQLException(message);
}
Any help would be greatly appreciated.
>From my server.xml:
<Resource name="jdbc/form_rev_DB" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/form_rev_DB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter><name>maxActive</name><value>100</value></parameter>
<parameter><name>maxIdle</name><value>30000</value></parameter>
<parameter><name>maxWait</name><value>100</value></parameter>
<parameter><name>username</name><value>tcuser</value></parameter>
<parameter><name>password</name><value>XXXXX</value></parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/form_rev</value>
</parameter>
</ResourceParams>
>From my web.xml:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/form_rev_DB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: BasicDataSourceFactory and TC 4.1.9
Posted by Nikola Milutinovic <Ni...@ev.co.yu>.
Paul McGovern wrote:
> Upon further investigation, I found that the config I use below does work if,
> and only if, I access the servlet from localhost:8080. I'm using mod_webapp
> with Apache 1.3.24 and have the following entry, which seems to work fine, in
> httpd.conf:
Lookup archives. This problem has been noted and it has to do with deployment
paths of the webapp. I recall that mod_webapp would deploy under different path
and that would cause resources not to get loaded *for mod_webapp only*.
Nix.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: BasicDataSourceFactory and TC 4.1.9
Posted by Paul McGovern <mc...@canuck.com>.
Upon further investigation, I found that the config I use below does work if,
and only if, I access the servlet from localhost:8080. I'm using mod_webapp
with Apache 1.3.24 and have the following entry, which seems to work fine, in
httpd.conf:
<IfModule mod_webapp.c>
WebAppConnection conn warp localhost:8008
WebAppDeploy examples conn /examples
WebAppDeploy formproc conn /formproc
WebAppInfo /webapp-info
</IfModule>
sertver.xml:
<Context path="/formproc" debug="5" docBase="formproc" reloadable="true">
web.xml:
<servlet-mapping>
<servlet-name>DBTestServlet</servlet-name>
<url-pattern>/dbTest</url-pattern>
</servlet-mapping>
So, "http://localhost/formproc/dbTest" fails to instantiate the Connection
properly, but "http://localhost:8080/formproc/dbTest" works properly.
Can anyone explain what is going on here?
(Sorry for the long post, but this is starting to drive me nuts.)
> I am having probelms getting a Connection from the DataSource I get out of
> JNDI. I set up the Resource section of my server.xml as described in the
> HOW-TO for 4.1.9 and am using mm.mysql 2.0.14 with MySQL 3.23.51. The DB
> and dirver seem to work fine together.
>
> It seems I can get the DataSource from the JNDI context as expected, but
> calling getConnection() yeilds an SQLException that says, "Cannot load JDBC
> driver class 'null'". The driver is sitting in common/lib and can be seen
> and used by servlets in my context if I do it 'by hand'. A quick look
> through DBCP's BasicDataSourceFactory confirms 'driverClassName' is the
> correct parameter name for the driver class, and the exception is being
> generated in BasicDataSource:
>
> // Load the JDBC driver class
> Class driverClass = null;
> try {
> driverClass = Class.forName(driverClassName);
> } catch (Throwable t) {
> String message = "Cannot load JDBC driver class '" +
> driverClassName + "'";
> logWriter.println(message);
> t.printStackTrace(logWriter);
> throw new SQLException(message);
> }
>
> Any help would be greatly appreciated.
>
>
> From my server.xml:
> <Resource name="jdbc/form_rev_DB" auth="Container"
> type="javax.sql.DataSource"/>
> <ResourceParams name="jdbc/form_rev_DB">
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> <parameter><name>maxActive</name><value>100</value></parameter>
> <parameter><name>maxIdle</name><value>30000</value></parameter>
> <parameter><name>maxWait</name><value>100</value></parameter>
> <parameter><name>username</name><value>tcuser</value></parameter>
> <parameter><name>password</name><value>XXXXX</value></parameter>
> <parameter>
> <name>driverClassName</name>
> <value>org.gjt.mm.mysql.Driver</value>
> </parameter>
> <parameter>
> <name>url</name>
> <value>jdbc:mysql://localhost:3306/form_rev</value>
> </parameter>
> </ResourceParams>
>
> From my web.xml:
> <resource-ref>
> <description>DB Connection</description>
> <res-ref-name>jdbc/form_rev_DB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: BasicDataSourceFactory and TC 4.1.9
Posted by Simon T <to...@sydneybluegum.com>.
Paul,
I have mysql working ok with mm.mysql-2.0.11-bin.jar
file in the common/lib
I am using the jdk1.3.1 with the full tomcat 4.1.19
installation.
Which JDK are you using?
The context web.xml needs to be updated for the context in the server.xml
e.g in the tomcat example they created DBTest <Context path="/DBTest" docBase="DBTest"
A jsp example that i used for testing
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#e0a0e0">
<%@page language="java" import="javax.sql.*"%>
<%@page import="javax.naming.*" %>
<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<%
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/mysql");
Connection conn = ds.getConnection();
Statement StatementRecordset1 = conn.createStatement();
ResultSet Recordset1 = StatementRecordset1.executeQuery("select * from
abc");
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
int Recordset1_numRows = 0;
int Repeat1__numRows = 100 ;
int Repeat1__index = 0 ;
Recordset1_numRows += Repeat1__numRows;
%>
<table BORDER=2>
<% while ((Recordset1_hasData)&&(Repeat1__numRows-- != 0))
{
%>
<tr>
<td><%= (String) Recordset1.getObject("name") %></td>
</tr>
<%Repeat1__index++;
Recordset1_hasData = Recordset1.next();}
Recordset1.close();
conn.close();
%>
</table>
</body></html
Regards,
Simon
Paul McGovern wrote:
>I am having probelms getting a Connection from the DataSource I get out of
>JNDI. I set up the Resource section of my server.xml as described in the
>HOW-TO for 4.1.9 and am using mm.mysql 2.0.14 with MySQL 3.23.51. The DB and
>dirver seem to work fine together.
>
>It seems I can get the DataSource from the JNDI context as expected, but
>calling getConnection() yeilds an SQLException that says, "Cannot load JDBC
>driver class 'null'". The driver is sitting in common/lib and can be seen and
>used by servlets in my context if I do it 'by hand'. A quick look through
>DBCP's BasicDataSourceFactory confirms 'driverClassName' is the correct
>parameter name for the driver class, and the exception is being generated in
>BasicDataSource:
>
> // Load the JDBC driver class
> Class driverClass = null;
> try {
> driverClass = Class.forName(driverClassName);
> } catch (Throwable t) {
> String message = "Cannot load JDBC driver class '" +
> driverClassName + "'";
> logWriter.println(message);
> t.printStackTrace(logWriter);
> throw new SQLException(message);
> }
>
>Any help would be greatly appreciated.
>
>
>>>From my server.xml:
><Resource name="jdbc/form_rev_DB" auth="Container"
>type="javax.sql.DataSource"/>
> <ResourceParams name="jdbc/form_rev_DB">
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
></parameter>
> <parameter><name>maxActive</name><value>100</value></parameter>
> <parameter><name>maxIdle</name><value>30000</value></parameter>
> <parameter><name>maxWait</name><value>100</value></parameter>
> <parameter><name>username</name><value>tcuser</value></parameter>
> <parameter><name>password</name><value>XXXXX</value></parameter>
> <parameter>
> <name>driverClassName</name>
> <value>org.gjt.mm.mysql.Driver</value>
> </parameter>
> <parameter>
> <name>url</name>
> <value>jdbc:mysql://localhost:3306/form_rev</value>
> </parameter>
></ResourceParams>
>
>>>From my web.xml:
> <resource-ref>
> <description>DB Connection</description>
> <res-ref-name>jdbc/form_rev_DB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
>--
>To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
java.lang.NullPointerException tc4.0.4
Posted by Luminous Heart <lu...@yahoo.com>.
I get this error the first time I try to access the
jsp page, if I reload it works fine. What is wrong?
Apache Tomcat/4.0.4 - HTTP Status 500 - Internal
Server Error
--------------------------------------------------------------------------------
type Exception report
message Internal Server Error
description The server encountered an internal error
(Internal Server Error) that prevented it from
fulfilling this request.
exception
java.lang.NullPointerException
at
org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:61)
at
org.postgresql.Connection.ExecSQL(Connection.java:398)
at
org.postgresql.jdbc2.Statement.execute(Statement.java:130)
at
org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
at
org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.java:99)
at
com.codestudio.sql.PoolManPreparedStatement.executeQuery(Unknown
Source)
at
org.apache.jsp.AccountAccess$jsp._jspService(AccountAccess$jsp.java:207)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:531)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:392)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:458)
at
org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:551)
at java.lang.Thread.run(Thread.java:536)
--------------------------------------------------------------------------------
__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>