You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Saurabh Nanda <sa...@gmail.com> on 2006/10/17 12:33:31 UTC

Database connection pooling errors in Tomcat 5.5.17

Hi,

I'm trying to configure a pooled database connection in Tomcat 5.5.17
but getting a strange error which looks like this:

java.lang.NullPointerException	
org.apache.tomcat.dbcp.dbcp.DelegatingConnection.close(DelegatingConnection.java:151)
org.apache.tomcat.dbcp.dbcp.PoolableConnection.reallyClose(PoolableConnection.java:95)
org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.destroyObject(PoolableConnectionFactory.java:301)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:883)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
testConf.TestConfServlet.doGet(TestConfServlet.java:37)
.... and so on

*** The META-INF/context.xml file has the following entry: ****
<Resource name="jdbc/myoracle"
	auth="Container"
	type="javax.sql.DataSource"
	driverClassName="oracle.jdbc.driver.OracleDriver"
	url="jdbc:oracle:thin:eps@192.168.0.253:1521:temp"
	username="temp"
	password="temp"
	maxActive="0"
	maxIdle="5"
	maxWait="10000"
	removeAbandoned="true"
	removeAbandonedTimeout="120"
	logAbandoned="true"
/>


*** Here's some sample code and output WITHOUT ERRORS: ****
Context ctx=new InitialContext();
NamingEnumeration list=ctx.list("java:/comp/env/jdbc");
out.write("<HTML><pre>");
NameClassPair pair;
while(list.hasMore()) {
	pair=(NameClassPair) list.nextElement();
	out.write(pair.getName() + "=" + pair.getClassName() + "\n");
}
DataSource ds=(DataSource) ctx.lookup("java:/comp/env/jdbc/myoracle");
out.write("ds=" + ds.toString() + "\n");

*** OUTPUT OF THE ABOVE CODE ****
myoracle=org.apache.tomcat.dbcp.dbcp.BasicDataSource
ds=org.apache.tomcat.dbcp.dbcp.BasicDataSource@1cb52ae

*** But as soon as I try to obtain a connection I start getting the
error I mentioned above!

I've spent a lot of time on this -- could someone please tell me where
I'm going wrong!

TIA
Nandz.
-- 
http://nandz.blogspot.com
http://foodieforlife.blogspot.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by David Smith <dn...@cornell.edu>.
One other thought I just had.  I don't use the Oracle driver, so bear 
with me.  Is there ever a case where the Oracle driver might return a 
null connection instead of throwing an exception?

David Smith wrote:

> Looks like the connection the pool is attempting to return is null.  
> Are there any errors further up the logs that might indicate an other 
> issue that might be causing this?  For what it's worth, the code and 
> config posted look good.
>
> --David
>
> Saurabh Nanda wrote:
>
>> Hi,
>>
>> I'm trying to configure a pooled database connection in Tomcat 5.5.17
>> but getting a strange error which looks like this:
>>
>> java.lang.NullPointerException   
>> org.apache.tomcat.dbcp.dbcp.DelegatingConnection.close(DelegatingConnection.java:151) 
>>
>> org.apache.tomcat.dbcp.dbcp.PoolableConnection.reallyClose(PoolableConnection.java:95) 
>>
>> org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.destroyObject(PoolableConnectionFactory.java:301) 
>>
>> org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:883) 
>>
>> org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851) 
>>
>> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) 
>>
>> testConf.TestConfServlet.doGet(TestConfServlet.java:37)
>> .... and so on
>>
>> *** The META-INF/context.xml file has the following entry: ****
>> <Resource name="jdbc/myoracle"
>>     auth="Container"
>>     type="javax.sql.DataSource"
>>     driverClassName="oracle.jdbc.driver.OracleDriver"
>>     url="jdbc:oracle:thin:eps@192.168.0.253:1521:temp"
>>     username="temp"
>>     password="temp"
>>     maxActive="0"
>>     maxIdle="5"
>>     maxWait="10000"
>>     removeAbandoned="true"
>>     removeAbandonedTimeout="120"
>>     logAbandoned="true"
>> />
>>
>>
>> *** Here's some sample code and output WITHOUT ERRORS: ****
>> Context ctx=new InitialContext();
>> NamingEnumeration list=ctx.list("java:/comp/env/jdbc");
>> out.write("<HTML><pre>");
>> NameClassPair pair;
>> while(list.hasMore()) {
>>     pair=(NameClassPair) list.nextElement();
>>     out.write(pair.getName() + "=" + pair.getClassName() + "\n");
>> }
>> DataSource ds=(DataSource) ctx.lookup("java:/comp/env/jdbc/myoracle");
>> out.write("ds=" + ds.toString() + "\n");
>>
>> *** OUTPUT OF THE ABOVE CODE ****
>> myoracle=org.apache.tomcat.dbcp.dbcp.BasicDataSource
>> ds=org.apache.tomcat.dbcp.dbcp.BasicDataSource@1cb52ae
>>
>> *** But as soon as I try to obtain a connection I start getting the
>> error I mentioned above!
>>
>> I've spent a lot of time on this -- could someone please tell me where
>> I'm going wrong!
>>
>> TIA
>> Nandz.
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by David Smith <dn...@cornell.edu>.
The "normal method" uses DriverManager.getConnection() which appears to 
cast a wider net in resolving database URLs.  Maybe someone who's seen 
the DriverManager class source can comment?

--David

Saurabh Nanda wrote:

> Thanks. I got it working:
>
> 1. Removed the oracle driver from WEB-INF/lib and put it in common/lib
> 2. Used the format of the URL given below:
> jdbc:oracle:thin:@address:port:schema
> -- but it's rather strange -- is this documented anywhere? When I was 
> using
> the "normal" (non DBCP) method to connect to the oracle DB my eariler URL
> string used to work!
>
>
> Here is a valid url :
>
>>
>> url="jdbc:oracle:thin:@address:port:schema"
>
>
>
>
> Thanks,
> Nandz.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by Saurabh Nanda <sa...@gmail.com>.
Thanks. I got it working:

1. Removed the oracle driver from WEB-INF/lib and put it in common/lib
2. Used the format of the URL given below:
jdbc:oracle:thin:@address:port:schema
-- but it's rather strange -- is this documented anywhere? When I was using
the "normal" (non DBCP) method to connect to the oracle DB my eariler URL
string used to work!


Here is a valid url :
>
> url="jdbc:oracle:thin:@address:port:schema"



Thanks,
Nandz.
-- 
http://nandz.blogspot.com
http://foodieforlife.blogspot.com

Re: Database connection pooling errors in Tomcat 5.5.17

Posted by David Smith <dn...@cornell.edu>.
Right, but that would have generated a different error -- 
ClassNotFoundException. 

Here, DBCP has a bug in that it get's connections using Driver.connect() 
and never checks to see if the connection object is not null.  The Sun 
JDK javadocs states a null return on Driver.connect() is normal and 
indicates the driver doesn't handle the given url.

--David

Martin Gainty wrote:

>You'll need to have a valid Driver class for the Class.forName statement e.g.
>
>private static Driver c_Driver =  (Driver)Class.forName( DriverClass ).newInstance();
>
>M-
>This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
>designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
>this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
>contents
>----- Original Message ----- 
>From: "DE VINZELLES, Guillaume (ext.)" <Gu...@neufcegetel.fr>
>To: "Tomcat Users List" <us...@tomcat.apache.org>
>Sent: Tuesday, October 17, 2006 11:18 AM
>Subject: RE: Database connection pooling errors in Tomcat 5.5.17
>
>
>Here is a valid url :
>
>url="jdbc:oracle:thin:@address:port:schema"
>
>Guillaume de Vinzelles
>DSI/PFS Neuf Cegetel
>Altran Technologies
> 
>guillaume.devinzelles@neufcegetel.fr
> 
>01 70 18 21 64
>
>-----Message d'origine-----
>De : David Smith [mailto:dns4@cornell.edu] 
>Envoyé : mardi 17 octobre 2006 17:16
>À : Tomcat Users List
>Objet : Re: Database connection pooling errors in Tomcat 5.5.17
>
>Some fishing through source and online -- your problem can happen if the 
>connection url is not recognized by the driver.
>
>I was looking at the jdbc url you first posted: 
>jdbc:oracle:thin:eps@....  This doesn't come up as a valid form in any 
>online docs I can find.  You might want to verify it's valid.
>
>--David
>
>Saurabh Nanda wrote:
>
>  
>
>>>ojdbc14.jar should be in $TOMCAT_HOME/common/lib to be available to both
>>>the container and your webapp.
>>>      
>>>
>>Nopes:
>>
>>o Put it in $CATALINA_HOME/common/lib alone -- same error
>>o put it in webapps/appname/WEB-INf/lib and $CATALINE_HOME/common/lib,
>>both -- same error!
>>
>>Does oracle drier support DBCP?
>>
>>Nandz.
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by Martin Gainty <mg...@hotmail.com>.
You'll need to have a valid Driver class for the Class.forName statement e.g.

private static Driver c_Driver =  (Driver)Class.forName( DriverClass ).newInstance();

M-
This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
contents
----- Original Message ----- 
From: "DE VINZELLES, Guillaume (ext.)" <Gu...@neufcegetel.fr>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, October 17, 2006 11:18 AM
Subject: RE: Database connection pooling errors in Tomcat 5.5.17


Here is a valid url :

url="jdbc:oracle:thin:@address:port:schema"

Guillaume de Vinzelles
DSI/PFS Neuf Cegetel
Altran Technologies
 
guillaume.devinzelles@neufcegetel.fr
 
01 70 18 21 64

-----Message d'origine-----
De : David Smith [mailto:dns4@cornell.edu] 
Envoyé : mardi 17 octobre 2006 17:16
À : Tomcat Users List
Objet : Re: Database connection pooling errors in Tomcat 5.5.17

Some fishing through source and online -- your problem can happen if the 
connection url is not recognized by the driver.

I was looking at the jdbc url you first posted: 
jdbc:oracle:thin:eps@....  This doesn't come up as a valid form in any 
online docs I can find.  You might want to verify it's valid.

--David

Saurabh Nanda wrote:

>> ojdbc14.jar should be in $TOMCAT_HOME/common/lib to be available to both
>> the container and your webapp.
>
>
> Nopes:
>
> o Put it in $CATALINA_HOME/common/lib alone -- same error
> o put it in webapps/appname/WEB-INf/lib and $CATALINE_HOME/common/lib,
> both -- same error!
>
> Does oracle drier support DBCP?
>
> Nandz.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Database connection pooling errors in Tomcat 5.5.17

Posted by "DE VINZELLES, Guillaume (ext.)" <Gu...@neufcegetel.fr>.
Here is a valid url :

url="jdbc:oracle:thin:@address:port:schema"

Guillaume de Vinzelles
DSI/PFS Neuf Cegetel
Altran Technologies
 
guillaume.devinzelles@neufcegetel.fr
 
01 70 18 21 64

-----Message d'origine-----
De : David Smith [mailto:dns4@cornell.edu] 
Envoyé : mardi 17 octobre 2006 17:16
À : Tomcat Users List
Objet : Re: Database connection pooling errors in Tomcat 5.5.17

Some fishing through source and online -- your problem can happen if the 
connection url is not recognized by the driver.

I was looking at the jdbc url you first posted: 
jdbc:oracle:thin:eps@....  This doesn't come up as a valid form in any 
online docs I can find.  You might want to verify it's valid.

--David

Saurabh Nanda wrote:

>> ojdbc14.jar should be in $TOMCAT_HOME/common/lib to be available to both
>> the container and your webapp.
>
>
> Nopes:
>
> o Put it in $CATALINA_HOME/common/lib alone -- same error
> o put it in webapps/appname/WEB-INf/lib and $CATALINE_HOME/common/lib,
> both -- same error!
>
> Does oracle drier support DBCP?
>
> Nandz.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by David Smith <dn...@cornell.edu>.
Some fishing through source and online -- your problem can happen if the 
connection url is not recognized by the driver.

I was looking at the jdbc url you first posted: 
jdbc:oracle:thin:eps@....  This doesn't come up as a valid form in any 
online docs I can find.  You might want to verify it's valid.

--David

Saurabh Nanda wrote:

>> ojdbc14.jar should be in $TOMCAT_HOME/common/lib to be available to both
>> the container and your webapp.
>
>
> Nopes:
>
> o Put it in $CATALINA_HOME/common/lib alone -- same error
> o put it in webapps/appname/WEB-INf/lib and $CATALINE_HOME/common/lib,
> both -- same error!
>
> Does oracle drier support DBCP?
>
> Nandz.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by David Smith <dn...@cornell.edu>.
Is the driver in exactly one place -- $TOMCAT_HOME/common/lib?  This is 
the only place the driver is documented to work from.  If the jar file 
is in multiple places it can cause classloader issues.  Related to that, 
also check it isn't in any classpath or the JVM endorsed folder.

Did you restart tomcat between attempts?

As I recall, all JDBC drivers return a more or less generic 
java.sql.Connection object so compatibility with the DBCP based pool is 
a non-issue.

--David

Saurabh Nanda wrote:

>> ojdbc14.jar should be in $TOMCAT_HOME/common/lib to be available to both
>> the container and your webapp.
>
>
> Nopes:
>
> o Put it in $CATALINA_HOME/common/lib alone -- same error
> o put it in webapps/appname/WEB-INf/lib and $CATALINE_HOME/common/lib,
> both -- same error!
>
> Does oracle drier support DBCP?
>
> Nandz.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Database connection pooling errors in Tomcat 5.5.17

Posted by "DE VINZELLES, Guillaume (ext.)" <Gu...@neufcegetel.fr>.
Yes, it does support DBCP.
(see my older post about DBCP pool exhaustion).

Regards.

Guillaume de Vinzelles
DSI/PFS Neuf Cegetel
Altran Technologies
 
guillaume.devinzelles@neufcegetel.fr
 
01 70 18 21 64

-----Message d'origine-----
De : Saurabh Nanda [mailto:saurabhnanda@gmail.com] 
Envoyé : mardi 17 octobre 2006 14:13
À : Tomcat Users List
Objet : Re: Database connection pooling errors in Tomcat 5.5.17

> ojdbc14.jar should be in $TOMCAT_HOME/common/lib to be available to both
> the container and your webapp.

Nopes:

o Put it in $CATALINA_HOME/common/lib alone -- same error
o put it in webapps/appname/WEB-INf/lib and $CATALINE_HOME/common/lib,
both -- same error!

Does oracle drier support DBCP?

Nandz.
-- 
http://nandz.blogspot.com
http://foodieforlife.blogspot.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by Saurabh Nanda <sa...@gmail.com>.
> ojdbc14.jar should be in $TOMCAT_HOME/common/lib to be available to both
> the container and your webapp.

Nopes:

o Put it in $CATALINA_HOME/common/lib alone -- same error
o put it in webapps/appname/WEB-INf/lib and $CATALINE_HOME/common/lib,
both -- same error!

Does oracle drier support DBCP?

Nandz.
-- 
http://nandz.blogspot.com
http://foodieforlife.blogspot.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by David Smith <dn...@cornell.edu>.
I think I see the problem...

ojdbc14.jar should be in $TOMCAT_HOME/common/lib to be available to both 
the container and your webapp. 

.jar files are always stored in a lib folder.  Relative to tomcat's home 
dir -- shared/lib, common/lib.  Relative to the webapp -- WEB-INF/lib

--David

Saurabh Nanda wrote:

> This is the complete stacktrace of the error if it helps. The
> ojdbc14.jar file is in the WEB-INF/classes directory.
>
> SEVERE: Servlet.service() for servlet test threw exception
> java.lang.NullPointerException
>        at 
> org.apache.tomcat.dbcp.dbcp.DelegatingConnection.close(DelegatingConnection.java:151) 
>
>        at 
> org.apache.tomcat.dbcp.dbcp.PoolableConnection.reallyClose(PoolableConnection.java:95) 
>
>        at 
> org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.destroyObject(PoolableConnectionFactory.java:301) 
>
>        at 
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:883) 
>
>        at 
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851) 
>
>        at 
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) 
>
>        at testConf.TestConfServlet.doGet(TestConfServlet.java:37)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
>        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:213) 
>
>        at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) 
>
>        at 
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432) 
>
>        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:869) 
>
>        at 
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) 
>
>        at 
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) 
>
>        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)
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by Saurabh Nanda <sa...@gmail.com>.
This is the complete stacktrace of the error if it helps. The
ojdbc14.jar file is in the WEB-INF/classes directory.

SEVERE: Servlet.service() for servlet test threw exception
java.lang.NullPointerException
        at org.apache.tomcat.dbcp.dbcp.DelegatingConnection.close(DelegatingConnection.java:151)
        at org.apache.tomcat.dbcp.dbcp.PoolableConnection.reallyClose(PoolableConnection.java:95)
        at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.destroyObject(PoolableConnectionFactory.java:301)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:883)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
        at testConf.TestConfServlet.doGet(TestConfServlet.java:37)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        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:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
        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:869)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        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)


-- 
http://nandz.blogspot.com
http://foodieforlife.blogspot.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Database connection pooling errors in Tomcat 5.5.17

Posted by David Smith <dn...@cornell.edu>.
Looks like the connection the pool is attempting to return is null.  Are 
there any errors further up the logs that might indicate an other issue 
that might be causing this?  For what it's worth, the code and config 
posted look good.

--David

Saurabh Nanda wrote:

> Hi,
>
> I'm trying to configure a pooled database connection in Tomcat 5.5.17
> but getting a strange error which looks like this:
>
> java.lang.NullPointerException   
> org.apache.tomcat.dbcp.dbcp.DelegatingConnection.close(DelegatingConnection.java:151) 
>
> org.apache.tomcat.dbcp.dbcp.PoolableConnection.reallyClose(PoolableConnection.java:95) 
>
> org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.destroyObject(PoolableConnectionFactory.java:301) 
>
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:883) 
>
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851) 
>
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) 
>
> testConf.TestConfServlet.doGet(TestConfServlet.java:37)
> .... and so on
>
> *** The META-INF/context.xml file has the following entry: ****
> <Resource name="jdbc/myoracle"
>     auth="Container"
>     type="javax.sql.DataSource"
>     driverClassName="oracle.jdbc.driver.OracleDriver"
>     url="jdbc:oracle:thin:eps@192.168.0.253:1521:temp"
>     username="temp"
>     password="temp"
>     maxActive="0"
>     maxIdle="5"
>     maxWait="10000"
>     removeAbandoned="true"
>     removeAbandonedTimeout="120"
>     logAbandoned="true"
> />
>
>
> *** Here's some sample code and output WITHOUT ERRORS: ****
> Context ctx=new InitialContext();
> NamingEnumeration list=ctx.list("java:/comp/env/jdbc");
> out.write("<HTML><pre>");
> NameClassPair pair;
> while(list.hasMore()) {
>     pair=(NameClassPair) list.nextElement();
>     out.write(pair.getName() + "=" + pair.getClassName() + "\n");
> }
> DataSource ds=(DataSource) ctx.lookup("java:/comp/env/jdbc/myoracle");
> out.write("ds=" + ds.toString() + "\n");
>
> *** OUTPUT OF THE ABOVE CODE ****
> myoracle=org.apache.tomcat.dbcp.dbcp.BasicDataSource
> ds=org.apache.tomcat.dbcp.dbcp.BasicDataSource@1cb52ae
>
> *** But as soon as I try to obtain a connection I start getting the
> error I mentioned above!
>
> I've spent a lot of time on this -- could someone please tell me where
> I'm going wrong!
>
> TIA
> Nandz.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org