You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by John Vasileff <jo...@gmail.com> on 2014/03/23 19:40:55 UTC

Tomcat JDBC, WebappClassLoader delegation

In Tomcat 8, WebappClassLoader disallows overrides of org.apache.tomcat.* classes which includes org.apache.tomcat.jdbc.*.  As a result, it is impossible to use the Tomcat JDBC pool with a JDBC driver in WEB-INF/lib. On Tomcat 7 this is possible by packaging both tomcat-jdbc.jar and the driver in WEB-INF/lib.

Would it be possible to add an exception for “org.apache.tomcat.jdbc” to the regex below to restore this capability?

    protected final Matcher packageTriggersPermit =
            Pattern.compile("^javax\\.servlet\\.jsp\\.jstl\\.").matcher("”);

I know the intent of the org.apache.x patterns in the corresponding packageTriggersDeny regex is to disallow overriding of container implementation classes. But really, the Tomcat JDBC Connection Pool is a reusable library that happens to share a package namespace with container classes. It is, after all, offered as a standalone module.

It is fair to debate whether it is a good idea to place JDBC drivers in WEB-INF/lib in the first place, but it's often quite convenient. Further, with the current behavior, applications using the Tomcat JDBC pool behave differently based on whether the container they are deployed on provides these non-servlet-spec classes, which seems a bit ugly, given that the module is intended for reuse.

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


Re: Tomcat JDBC, WebappClassLoader delegation

Posted by John Vasileff <jo...@gmail.com>.
On Mar 23, 2014, at 3:06 PM, Mark Thomas <ma...@apache.org> wrote:

> On 23/03/2014 18:40, John Vasileff wrote:
>> Would it be possible to add an exception for “org.apache.tomcat.jdbc”
>> to the regex below to restore this capability?
>> 
>> protected final Matcher packageTriggersPermit = 
>> Pattern.compile("^javax\\.servlet\\.jsp\\.jstl\\.").matcher("”);
> 
> Seems reasonable.
> 
> I've applied a fix to 8.0.x which will be included in 8.0.5 onwards.
> 
> Mark

Awesome, thanks!

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


Re: Tomcat JDBC, WebappClassLoader delegation

Posted by Mark Thomas <ma...@apache.org>.
On 23/03/2014 18:40, John Vasileff wrote:
> In Tomcat 8, WebappClassLoader disallows overrides of
> org.apache.tomcat.* classes which includes org.apache.tomcat.jdbc.*.
> As a result, it is impossible to use the Tomcat JDBC pool with a JDBC
> driver in WEB-INF/lib. On Tomcat 7 this is possible by packaging both
> tomcat-jdbc.jar and the driver in WEB-INF/lib.

Strictly, that is not correct. If you remove tomcat-jdbc.jar from the
$CATALINA_HOME/lib the version in the web application should be used.

> Would it be possible to add an exception for “org.apache.tomcat.jdbc”
> to the regex below to restore this capability?
> 
> protected final Matcher packageTriggersPermit = 
> Pattern.compile("^javax\\.servlet\\.jsp\\.jstl\\.").matcher("”);

Seems reasonable.

I've applied a fix to 8.0.x which will be included in 8.0.5 onwards.

Mark

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