You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2016/02/26 19:52:52 UTC

[Bug 59077] New: DataSourceFactory creates a neutered data source

https://bz.apache.org/bugzilla/show_bug.cgi?id=59077

            Bug ID: 59077
           Summary: DataSourceFactory creates a neutered data source
           Product: Tomcat 8
           Version: 8.0.30
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: kenneth.gendron@gmail.com

Suppose you have a datasource, "jdbc/ds" below, that for whatever reason the
backing database is down and cannot be connected to.  When Tomcat starts up it
attempts to create the pooled datasource "jdbc/dspool"; however, due to the
pseudo-random nature of how Tomcat creates resources the "jdbc/ds" datasource
is not yet created.  This does not pose a problem to the DataSourceFactory
class since the performJNDILookup method does not throw an exception, but fails
with only a log message.  Tomcat does not retry to create the pooled
datasource, and proceeds on, failing later on for "URL cannot be found", or
some such error.  Below is the server.xml configuration portion.

<Resource name="jdbc/automationora"
              auth="Container"
              type="javax.sql.DataSource"
              username="automation"
              password="automation"
              factory="automation.sql.oracle.OracleDataSourceFactory"
             
url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)))"
              connectionProperties="oracle.jdbc.ReadTimeout=60000;"/>
    <Resource name="jdbc/automation"
              auth="Container"
              type="javax.sql.DataSource"
              factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
              dataSourceJNDI="automationora"
              maxActive="5"
              maxIdle="5"
              minIdle="5"
              maxWait="-1"
              initialSize="0"
              testOnBorrow="true"
              validationQuery="select 1 from dual"/>

If, however, the performJNDILookup were modified to allow an Exception, namely
a NamingException to be thrown, then it could be modified slightly to allow
Tomcat to retry.  Below, when the method fails to find the data source in the
initial context, it could throw the resulting NamingException.  Tomcat would
then continue with the other resources, creating them, then come back and
recreate the pooled datasource.

    public void performJNDILookup(Context context, PoolConfiguration
poolProperties) throws NamingException {
        Object jndiDS = null;
        try {
            if (context!=null) {
                jndiDS = context.lookup(poolProperties.getDataSourceJNDI());
            } else {
                log.warn("dataSourceJNDI property is configued, but local JNDI
context is null.");
            }
        } catch (NamingException e) {
            log.debug("The name \""+poolProperties.getDataSourceJNDI()+"\" can
not be found in the local context.");
        }
        if (jndiDS==null) {
            try {
                context = new InitialContext();
                jndiDS = context.lookup(poolProperties.getDataSourceJNDI());
            } catch (NamingException e) {
                log.warn("The name \""+poolProperties.getDataSourceJNDI()+"\"
can not be found in the InitialContext.");
                throw e;
            }
        }
        if (jndiDS!=null) {
            poolProperties.setDataSource(jndiDS);
        }
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59077] DataSourceFactory creates a neutered data source

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59077

--- Comment #3 from Christopher Schultz <ch...@christopherschultz.net> ---
(In reply to Kenneth Gendron from comment #2)
> Sorry to ask, but does this mean its by design, or should be fixed?

I believe Mark changed the "product" field in the bug report and made a comment
to that effect. It's not a comment on the validity of the bug report itself.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59077] DataSourceFactory creates a neutered data source

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59077

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Catalina                    |jdbc-pool
            Version|8.0.30                      |unspecified
            Product|Tomcat 8                    |Tomcat Modules
   Target Milestone|----                        |---
                 OS|                            |All

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
Correct product.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59077] DataSourceFactory creates a neutered data source

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59077

--- Comment #2 from Kenneth Gendron <ke...@gmail.com> ---
Sorry to ask, but does this mean its by design, or should be fixed?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org