vibur / vibur-dbcp

Vibur DBCP - concurrent and dynamic JDBC connection pool
http://www.vibur.org
Apache License 2.0
96 stars 11 forks source link

configureFromProperties throws Exception when configured as JNDI resource #5

Closed dcalde closed 8 years ago

dcalde commented 8 years ago

When declared as JNDI resource ViburDBCPDataSource.configureFromProperties() throws a ViburDBCPException, e.g. "Unexpected configuration property: auth"

<Resource auth="Container" name="jdbc/xxxx" type="javax.sql.DataSource" 
    driverClassName="org.postgresql.Driver" 
    factory="org.vibur.dbcp.ViburDBCPObjectFactory" ...  />

This can either be fixed by excluding all parameters by name in ViburDBCPObjectFactory e.g.

if("auth".equals(pname)
        || "singleton".equals(pname)
        || "description".equals(pname)
        || "type".equals(pname)
        || "scope".equals(pname)
        || "factory".equals(pname)
        || "closeMethod".equals(pname)) {
    /*
      need to skip these parameters as otherwise org.vibur.dbcp.ViburDBCPDataSource.configureFromProperties()
      throws a ViburDBCPException("Unexpected configuration property: " + key);
     */
    continue;
}

Or, as this is very cumbersome to maintain across Application Servers, to rather log a warning than throw an Exception

} catch (NoSuchFieldException e) {
    //throw new ViburDBCPException("Unexpected configuration property: " + key);
    logger.warn("Unexpected configuration property: " + key);
}
simeonmalchev commented 8 years ago

This should be now fixed on master branch. If possible can you please take a build from master and retest?

I'll keep this issue open until next Vibur DBCP release is done and uploaded to Maven central, but the issue should be fixed now.

simeonmalchev commented 8 years ago

Fixed in release 6.0.