You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Darren Hall <dh...@utrs.com> on 2006/09/18 16:56:32 UTC

Database connection pooling in Tomcat 5.5

Hi all.

 

I'm attempting to set up database connection pool using Tomcat 5.5 and
Oracle 10g. I've been following the "JNDI How To" guide from Apache
(http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
). My question is - where should I define the connection pool resource?
Meaning, where should my "Resource" element appear. I've read two different
descriptions about how this should be done in the Apache documentation. The
first description (from the above link) states that I should modify
server.xml and add a new Context element as such <Context path="/DBTest"
docBase="DBTest" debug="5" reloadable="true" crossContext="true"> and in
that new context define my resource for my connection pool. However, if you
read the "Context" documentation linked to the above How-To (located at this
link: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html) you'll
find in there the following text - "Please note that for tomcat 5, unlike
tomcat 4.x, it is NOT recommended to place <Context> elements directly in
the server.xml file. Instead, put them in the META-INF/context.xml directory
of your WAR file or the conf directory". So I'm wondering if I should modify
server.xml or create a context.xml file. Currently I'm trying the
context.xml file route, but it is not working (although this could be
because I'm configuring things incorrectly). Can anyone point me in the
right direction here?
 
Thanks,
Darren

 


RE: Database connection pooling in Tomcat 5.5

Posted by Darren Hall <dh...@utrs.com>.
Yes, I did. Here is the web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
  <display-name>My Web Application</display-name>
  <description>
    Web Application.
  </description> 

  <!-- Action Servlet Configuration -->
  <servlet>
    <servlet-name>primary-controller</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <!-- Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>primary-controller</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

  <!-- The Welcome File List -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

  <resource-ref>
    <description>Oracle Datasource connection pool</description>
    <res-ref-name>jdbc/flc</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

</web-app>




-----Original Message-----
From: Mark Barnes [mailto:mark.barnes@coat.com] 
Sent: Monday, September 18, 2006 11:30 AM
To: Tomcat Users List
Subject: Re: Database connection pooling in Tomcat 5.5

Do you include a <resource-ref> in your WEB-INF/web.xml file?

You might also want to post your web.xml


Pid wrote:
> post your context.xml
> 
> 
> 
> 
> Darren Hall wrote:
>> Hi all.
>>
>>  
>>
>> I'm attempting to set up database connection pool using Tomcat 5.5 and
>> Oracle 10g. I've been following the "JNDI How To" guide from Apache
>>
(http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
>> ). My question is - where should I define the connection pool resource?
>> Meaning, where should my "Resource" element appear. I've read two
different
>> descriptions about how this should be done in the Apache documentation.
The
>> first description (from the above link) states that I should modify
>> server.xml and add a new Context element as such <Context path="/DBTest"
>> docBase="DBTest" debug="5" reloadable="true" crossContext="true"> and in
>> that new context define my resource for my connection pool. However, if
you
>> read the "Context" documentation linked to the above How-To (located at
this
>> link: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html) you'll
>> find in there the following text - "Please note that for tomcat 5, unlike
>> tomcat 4.x, it is NOT recommended to place <Context> elements directly in
>> the server.xml file. Instead, put them in the META-INF/context.xml
directory
>> of your WAR file or the conf directory". So I'm wondering if I should
modify
>> server.xml or create a context.xml file. Currently I'm trying the
>> context.xml file route, but it is not working (although this could be
>> because I'm configuring things incorrectly). Can anyone point me in the
>> right direction here?
>>  
>> Thanks,
>> Darren
>>
>>  
>>
>>
> 
> 
> ---------------------------------------------------------------------
> 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 in Tomcat 5.5

Posted by Mark Barnes <ma...@coat.com>.
Do you include a <resource-ref> in your WEB-INF/web.xml file?

You might also want to post your web.xml


Pid wrote:
> post your context.xml
> 
> 
> 
> 
> Darren Hall wrote:
>> Hi all.
>>
>>  
>>
>> I'm attempting to set up database connection pool using Tomcat 5.5 and
>> Oracle 10g. I've been following the "JNDI How To" guide from Apache
>> (http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
>> ). My question is - where should I define the connection pool resource?
>> Meaning, where should my "Resource" element appear. I've read two different
>> descriptions about how this should be done in the Apache documentation. The
>> first description (from the above link) states that I should modify
>> server.xml and add a new Context element as such <Context path="/DBTest"
>> docBase="DBTest" debug="5" reloadable="true" crossContext="true"> and in
>> that new context define my resource for my connection pool. However, if you
>> read the "Context" documentation linked to the above How-To (located at this
>> link: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html) you'll
>> find in there the following text - "Please note that for tomcat 5, unlike
>> tomcat 4.x, it is NOT recommended to place <Context> elements directly in
>> the server.xml file. Instead, put them in the META-INF/context.xml directory
>> of your WAR file or the conf directory". So I'm wondering if I should modify
>> server.xml or create a context.xml file. Currently I'm trying the
>> context.xml file route, but it is not working (although this could be
>> because I'm configuring things incorrectly). Can anyone point me in the
>> right direction here?
>>  
>> Thanks,
>> Darren
>>
>>  
>>
>>
> 
> 
> ---------------------------------------------------------------------
> 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 in Tomcat 5.5

Posted by Darren Hall <dh...@utrs.com>.
I've made some progress on this. I'm now receiving a "SQLNestedException:
Cannot create PoolableConnectionFactory" error when calling getConnection on
the DataSource object retrieved from my connection pool. Here is the satck
trace:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (ORA-01017: invalid username/password; logon
denied
)
	at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource
.java:855)
	at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.ja
va:540)
	at
org.federallabs.labs.LaboratorySearchAction.execute(LaboratorySearchAction.j
ava:99)

Problem is - I know the username and password are correct. Anyone have any
ideas what could be causing my issue? I need to get this connection pool
issue working by the end of work today.

Thanks,
Darren


---------------------------------------------------------------------
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 in Tomcat 5.5

Posted by Darren Hall <dh...@utrs.com>.
Here's another question...
If the database pool is not created properly, will it fail silently, or will
an error be displayed in a log file? And if an error is output to a log
file, which one will it be?


-----Original Message-----
From: Darren Hall [mailto:dhall@utrs.com] 
Sent: Monday, September 18, 2006 12:31 PM
To: 'Tomcat Users List'
Subject: RE: Database connection pooling in Tomcat 5.5

The issue could be the path attribute or docbase attribute in the
context.xml. I'm not sure what values should appear for these.


-----Original Message-----
From: Darren Hall [mailto:dhall@utrs.com] 
Sent: Monday, September 18, 2006 11:26 AM
To: 'Tomcat Users List'
Subject: RE: Database connection pooling in Tomcat 5.5

Here it is. The items in parenthesis have been removed.
Thanks for the help.


<Context path="/flc" docBase="flc"
        debug="5" reloadable="true" crossContext="true">

    <!-- maxActive: Maximum number of dB connections in pool. Make sure you
         configure your oracle max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         -->

    <!-- maxIdle: Maximum number of idle dB connections to retain in pool.
         Set to -1 for no limit.  See also the DBCP documentation on this
         and the minEvictableIdleTimeMillis configuration parameter.
         -->

    <!-- maxWait: Maximum time to wait for a dB connection to become
available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded.  Set to -1 to wait indefinitely.
         -->

    <!-- username and password: Oracle dB username and password for dB
connections  -->

    <!-- driverClassName: Class name for the official Oracle thin driver is 
         oracle.jdbc.OracleDriver.
         -->
    
    <!-- url: The JDBC connection url for connecting to your Oracle dB.
         -->

    <Resource name="jdbc/flc" auth="Container"
              type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@(dbserver.domain.com):1521:(mysid)"
              username="(user)" password="(passwd)" maxActive="20"
maxIdle="10"
              maxWait="-1" removeAbandoned="true"
removeAbandonedTimeout="180"
              logAbandoned="true"/> 
</Context>




-----Original Message-----
From: Pid [mailto:p@pidster.com] 
Sent: Monday, September 18, 2006 11:16 AM
To: Tomcat Users List
Subject: Re: Database connection pooling in Tomcat 5.5

post your context.xml




Darren Hall wrote:
> Hi all.
> 
>  
> 
> I'm attempting to set up database connection pool using Tomcat 5.5 and
> Oracle 10g. I've been following the "JNDI How To" guide from Apache
>
(http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> ). My question is - where should I define the connection pool resource?
> Meaning, where should my "Resource" element appear. I've read two
different
> descriptions about how this should be done in the Apache documentation.
The
> first description (from the above link) states that I should modify
> server.xml and add a new Context element as such <Context path="/DBTest"
> docBase="DBTest" debug="5" reloadable="true" crossContext="true"> and in
> that new context define my resource for my connection pool. However, if
you
> read the "Context" documentation linked to the above How-To (located at
this
> link: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html) you'll
> find in there the following text - "Please note that for tomcat 5, unlike
> tomcat 4.x, it is NOT recommended to place <Context> elements directly in
> the server.xml file. Instead, put them in the META-INF/context.xml
directory
> of your WAR file or the conf directory". So I'm wondering if I should
modify
> server.xml or create a context.xml file. Currently I'm trying the
> context.xml file route, but it is not working (although this could be
> because I'm configuring things incorrectly). Can anyone point me in the
> right direction here?
>  
> Thanks,
> Darren
> 
>  
> 
> 


---------------------------------------------------------------------
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



---------------------------------------------------------------------
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 in Tomcat 5.5

Posted by Darren Hall <dh...@utrs.com>.
The issue could be the path attribute or docbase attribute in the
context.xml. I'm not sure what values should appear for these.


-----Original Message-----
From: Darren Hall [mailto:dhall@utrs.com] 
Sent: Monday, September 18, 2006 11:26 AM
To: 'Tomcat Users List'
Subject: RE: Database connection pooling in Tomcat 5.5

Here it is. The items in parenthesis have been removed.
Thanks for the help.


<Context path="/flc" docBase="flc"
        debug="5" reloadable="true" crossContext="true">

    <!-- maxActive: Maximum number of dB connections in pool. Make sure you
         configure your oracle max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         -->

    <!-- maxIdle: Maximum number of idle dB connections to retain in pool.
         Set to -1 for no limit.  See also the DBCP documentation on this
         and the minEvictableIdleTimeMillis configuration parameter.
         -->

    <!-- maxWait: Maximum time to wait for a dB connection to become
available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded.  Set to -1 to wait indefinitely.
         -->

    <!-- username and password: Oracle dB username and password for dB
connections  -->

    <!-- driverClassName: Class name for the official Oracle thin driver is 
         oracle.jdbc.OracleDriver.
         -->
    
    <!-- url: The JDBC connection url for connecting to your Oracle dB.
         -->

    <Resource name="jdbc/flc" auth="Container"
              type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@(dbserver.domain.com):1521:(mysid)"
              username="(user)" password="(passwd)" maxActive="20"
maxIdle="10"
              maxWait="-1" removeAbandoned="true"
removeAbandonedTimeout="180"
              logAbandoned="true"/> 
</Context>




-----Original Message-----
From: Pid [mailto:p@pidster.com] 
Sent: Monday, September 18, 2006 11:16 AM
To: Tomcat Users List
Subject: Re: Database connection pooling in Tomcat 5.5

post your context.xml




Darren Hall wrote:
> Hi all.
> 
>  
> 
> I'm attempting to set up database connection pool using Tomcat 5.5 and
> Oracle 10g. I've been following the "JNDI How To" guide from Apache
>
(http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> ). My question is - where should I define the connection pool resource?
> Meaning, where should my "Resource" element appear. I've read two
different
> descriptions about how this should be done in the Apache documentation.
The
> first description (from the above link) states that I should modify
> server.xml and add a new Context element as such <Context path="/DBTest"
> docBase="DBTest" debug="5" reloadable="true" crossContext="true"> and in
> that new context define my resource for my connection pool. However, if
you
> read the "Context" documentation linked to the above How-To (located at
this
> link: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html) you'll
> find in there the following text - "Please note that for tomcat 5, unlike
> tomcat 4.x, it is NOT recommended to place <Context> elements directly in
> the server.xml file. Instead, put them in the META-INF/context.xml
directory
> of your WAR file or the conf directory". So I'm wondering if I should
modify
> server.xml or create a context.xml file. Currently I'm trying the
> context.xml file route, but it is not working (although this could be
> because I'm configuring things incorrectly). Can anyone point me in the
> right direction here?
>  
> Thanks,
> Darren
> 
>  
> 
> 


---------------------------------------------------------------------
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 in Tomcat 5.5

Posted by Darren Hall <dh...@utrs.com>.
Here it is. The items in parenthesis have been removed.
Thanks for the help.


<Context path="/flc" docBase="flc"
        debug="5" reloadable="true" crossContext="true">

    <!-- maxActive: Maximum number of dB connections in pool. Make sure you
         configure your oracle max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         -->

    <!-- maxIdle: Maximum number of idle dB connections to retain in pool.
         Set to -1 for no limit.  See also the DBCP documentation on this
         and the minEvictableIdleTimeMillis configuration parameter.
         -->

    <!-- maxWait: Maximum time to wait for a dB connection to become
available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded.  Set to -1 to wait indefinitely.
         -->

    <!-- username and password: Oracle dB username and password for dB
connections  -->

    <!-- driverClassName: Class name for the official Oracle thin driver is 
         oracle.jdbc.OracleDriver.
         -->
    
    <!-- url: The JDBC connection url for connecting to your Oracle dB.
         -->

    <Resource name="jdbc/flc" auth="Container"
              type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@(dbserver.domain.com):1521:(mysid)"
              username="(user)" password="(passwd)" maxActive="20"
maxIdle="10"
              maxWait="-1" removeAbandoned="true"
removeAbandonedTimeout="180"
              logAbandoned="true"/> 
</Context>




-----Original Message-----
From: Pid [mailto:p@pidster.com] 
Sent: Monday, September 18, 2006 11:16 AM
To: Tomcat Users List
Subject: Re: Database connection pooling in Tomcat 5.5

post your context.xml




Darren Hall wrote:
> Hi all.
> 
>  
> 
> I'm attempting to set up database connection pool using Tomcat 5.5 and
> Oracle 10g. I've been following the "JNDI How To" guide from Apache
>
(http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> ). My question is - where should I define the connection pool resource?
> Meaning, where should my "Resource" element appear. I've read two
different
> descriptions about how this should be done in the Apache documentation.
The
> first description (from the above link) states that I should modify
> server.xml and add a new Context element as such <Context path="/DBTest"
> docBase="DBTest" debug="5" reloadable="true" crossContext="true"> and in
> that new context define my resource for my connection pool. However, if
you
> read the "Context" documentation linked to the above How-To (located at
this
> link: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html) you'll
> find in there the following text - "Please note that for tomcat 5, unlike
> tomcat 4.x, it is NOT recommended to place <Context> elements directly in
> the server.xml file. Instead, put them in the META-INF/context.xml
directory
> of your WAR file or the conf directory". So I'm wondering if I should
modify
> server.xml or create a context.xml file. Currently I'm trying the
> context.xml file route, but it is not working (although this could be
> because I'm configuring things incorrectly). Can anyone point me in the
> right direction here?
>  
> Thanks,
> Darren
> 
>  
> 
> 


---------------------------------------------------------------------
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 in Tomcat 5.5

Posted by Pid <p...@pidster.com>.
post your context.xml




Darren Hall wrote:
> Hi all.
> 
>  
> 
> I'm attempting to set up database connection pool using Tomcat 5.5 and
> Oracle 10g. I've been following the "JNDI How To" guide from Apache
> (http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> ). My question is - where should I define the connection pool resource?
> Meaning, where should my "Resource" element appear. I've read two different
> descriptions about how this should be done in the Apache documentation. The
> first description (from the above link) states that I should modify
> server.xml and add a new Context element as such <Context path="/DBTest"
> docBase="DBTest" debug="5" reloadable="true" crossContext="true"> and in
> that new context define my resource for my connection pool. However, if you
> read the "Context" documentation linked to the above How-To (located at this
> link: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html) you'll
> find in there the following text - "Please note that for tomcat 5, unlike
> tomcat 4.x, it is NOT recommended to place <Context> elements directly in
> the server.xml file. Instead, put them in the META-INF/context.xml directory
> of your WAR file or the conf directory". So I'm wondering if I should modify
> server.xml or create a context.xml file. Currently I'm trying the
> context.xml file route, but it is not working (although this could be
> because I'm configuring things incorrectly). Can anyone point me in the
> right direction here?
>  
> Thanks,
> Darren
> 
>  
> 
> 


---------------------------------------------------------------------
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