tomcat6 does not include tomcat-dbcp.jar

Reported by Max on 2008-10-15
This bug affects 3 people
Affects Status Importance Assigned to Milestone
tomcat6 (Ubuntu)
Thierry Carrez

Bug Description

Binary package hint: tomcat6

The new tomcat6 package in intrepid does not include tomcat-dbcp.jar. According to http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html, this should be present in $CATALINA_HOME/lib as part of the default installation, but it is not part of the package and does not appear to be provided by any other packages in ibex.

This is against tomcat6 6.0.18-0ubuntu1.

Thierry Carrez (ttx) wrote :

tomcat-dbcp.jar is a "package renamed database connection pool based on Commons DBCP", basically a JAR rebuilt from commons-dbcp and commons-pool JAR binaries. We ship those as links in lib/ instead.

It is in debian policy to build everything from source, and the tomcat-dbcp.jar in Tomcat is built from a binary, making it non-acceptable, that's the reason why we use the original commons-* libs instead. This also avoids code duplication which is bad from a distribution perspective.

Except the fact that some examples in the docs need to be adapted, could you find an example of something that doesn't work because we use the regular commons-* libs ? Does anything fail ?

Changed in tomcat6:
status: New → Incomplete
Max (mjs510) wrote :

I'm trying to run a 3rd party, closed source application on my Ubuntu Tomcat install. When I try to start Tomcat with it installed, I get the following in catalina.out:

WARNING: Failed to register in JMX: javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory]

I presume this means that the application is expecting to find the tomcat dbcp classes specifically and won't work with the commons ones. This application installs and runs perfectly using a downloaded Tomcat 6 install from tomcat.apache.org. The only way I could get it running using the Ubuntu Tomcat packages was to manually copy tomcat-dbcp.jar into the class path.

Thierry Carrez (ttx) wrote :

This is definitely a problem for prepackaged WARs that expect DBCP to live under org.apache.tomcat.dbcp.dbcp and not org.apache.commons.dbcp. It would have been better if Tomcat wouldn't have "repackaged" those but we still need to come up with a solution...

Like you said, the workaround is to use tomcat-dbcp.jar from tomcat.apache.org.

Changed in tomcat6:
importance: Undecided → Medium
status: Incomplete → Confirmed
Vincent DAVY (vincentdavy) wrote :


I confirm this bug.

I had to add the missing jar tomcat-dbcp.jar manually copied from another tomcat 6.
After adding it was successfully loading datasource settings.
And my webapp is fully working.

To solve the problem waiting for a fix, just get the tomcat-dbcp.jar from another tomcat 6 and copy it under /usr/share/tomcat6/lib.

Richard Andreu (randreu) wrote :

In Tomcat 5.5 the default database connection pool factory class is 'org.apache.commons.dbcp.BasicDataSourceFactory', included in commons-dbcp.jar. So, the applications that didn't specify the dbcp factory class (the great majority, I guess) worked with no problems using tomcat 5.5 without tomcat-dbcp.jar in the 'commons/lib' folder. The problem is that starting from Tomcat 6, the default database connection pool factory class is 'org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory' included in tomcat-dbcp.jar, so all the applications that expects to work with Tomcat's default database connection pool factory will fail if tomcat-dbcp.jar is not in the classpath.

Thierry Carrez (ttx) wrote :

Richard: good catch ! Tomcat 5.5 indeed changed the default from upstream, we should at least do the same for Tomcat 6. This might solve most of the cases where a tomcat-dbcp.jar copy was needed.

I'll need you guys to validate the fix : I'll soon provide a tomcat6 build for intrepid in my PPA so that you can test if this is sufficient to fix the issue in your case.

Changed in tomcat6:
assignee: nobody → tcarrez
status: Confirmed → In Progress
Thierry Carrez (ttx) wrote :

tomcat6 6.0.18-0ubuntu3.1~ppa1 published at https://launchpad.net/~tcarrez/+archive

Could those interested confirm if this version fixes the issue for them (i.e they don't need to copy tomcat-dbcp.jar anymore) ? I need some validation before pushing this to the archives.

Max (mjs510) wrote :

Yes, that version does fix the problem for me. After installing it from your ppa, I was able to remove tomcat-dbcp.jar from my system. Thanks for all your hard work!

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package tomcat6 - 6.0.18-0ubuntu4

tomcat6 (6.0.18-0ubuntu4) jaunty; urgency=low

  * tomcat6.init, tomcat6.postinst, tomcat6.dirs, tomcat6.default,
    README.debian: Use /tmp/tomcat6-temp instead of /var/lib/tomcat6/temp as
    the JVM temporary directory and clean it at each restart (LP: #287452)
  * policy/04webapps.policy: add rules to allow usage of java.io.tmpdir
  * tomcat6.init, rules: Do not use TearDown, as this results in
    LifecycleListener callbacks in webapps being bypassed (LP: #299436)
  * rules: Compile at Java 1.5 level to allow usage of Java 5 JREs
    (LP: #286427)
  * control, rules, libservlet2.5-java-doc.install,
    libservlet2.5-java-doc.links: New libservlet2.5-java-doc package ships
    missing Servlet/JSP API documentation (LP: #279645)
  * patches/use-commons-dbcp.patch: Change default DBCP factory class
    to org.apache.commons.dbcp.BasicDataSourceFactory (LP: #283852)
  * tomcat6.dirs, tomcat6.postinst, default_root/index.html: Create
    Catalina/localhost in /etc/tomcat6 and make it writeable by the tomcat6
    group, so that autodeploy and admin webapps work as expected (LP: #294277)
  * patches/disable-apr-loading.patch: Disable APR library loading until we
    properly provide it.
  * patches/disable-ajp-connector: Do not load AJP13 connector by default
    (LP: #300697)
  * rules: minor fixes to prevent build being called twice.

 -- Thierry Carrez <email address hidden> Thu, 27 Nov 2008 12:47:42 +0000

Changed in tomcat6:
status: In Progress → Fix Released
Thierry Carrez (ttx) wrote :

Max, Richard & others, I need your help: in order to issue an official update for Intrepid, we need an easy test case to demonstrate the bug in the current version and show that the proposed update fixes it.

Could you provide a minimal example webapp that could be used by verifiers ? Thanks in advance for your help.

Thierry Carrez (ttx) wrote :

Minimal patch for Intrepid SRU

Max (mjs510) wrote :

I'm afraid that I can't. I'm not a Java webapp developer and the application that I found the bug with is commercial.

Thierry Carrez (ttx) wrote :

Intrepid SRU Report

Bug impact: Tomcat 6 currently points to a default DBCP factory class that isn't provided in the package (org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory). That makes all web applications that don't specify a DBCP factory class fail. We provide org.apache.commons.dbcp.BasicDataSourceFactory to that effect, so Tomcat 6 should use that class by default.

Versions affected: Intrepid (tomcat6 didn't exist before)
Fix in development branch: Was fixed in 6.0.18-0ubuntu4 (see comment 10)

Minimal patch: see comment 12 above. The patch does the same thing the Tomcat 5.5 package always did, and fixes the shipped documentation accordingly. If accepted, this will be released as a combined SRU with bug 294277.

$ Get the two attached files (test-dbcp.tar and test-dbcp.xml)
$ sudo apt-get install tomcat6-examples
$ sudo /etc/init.d/tomcat6 stop
$ cd /var/lib/tomcat6/webapps && sudo tar xvf ~/test-dbcp.tar
$ sudo cp ~/test-dbcp.xml /etc/tomcat6/Catalina/localhost
$ sudo /etc/init.d/tomcat6 start
let a few seconds pass, then access http://localhost:8080/test-dbcp

With an unpatched Tomcat 6 you get an exception page, with root cause:
javax.servlet.ServletException: javax.naming.NamingException: Could not create resource factory instance [Root exception is java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.org.apache.tomcat.dbcp.dbcp)]
This shows you're trying to access the (not provided) org.apache.tomcat.dbcp.dbcp package

With a patched Tomcat6 you get the JSP ("Sample Application JSP Page") displayed correctly.

Regression potential:
People that downloaded tomcat-dbcp.jar (which contains the missing org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory) from the ASF website as a workaround to this bug might, after this update, use org.apache.commons.dbcp.BasicDataSourceFactory instead. This shouldn't trigger any issue since the two factories should act the same.

Thierry Carrez (ttx) wrote :

The second file needed for the test case.

Martin Pitt (pitti) wrote :

SRU Ack, please upload.

Changed in tomcat6:
status: New → Confirmed
Craig (candrews-integralblue) wrote :

Any news on this going to Intrepid?

Thierry Carrez (ttx) wrote :

It is still stuck on sponsoring. I'll try to push this next week to someone that can upload it.

Thierry Carrez (ttx) wrote :

In fact it is uploaded, it's just sitting in the Unapproved queue at the moment.

Martin Pitt (pitti) wrote :

Accepted into intrepid-proposed, please test and give feedback here. Please see https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in tomcat6:
status: Confirmed → Fix Committed
Thierry Carrez (ttx) wrote :

Ran test case with current tomcat6-6.0.18-0ubuntu3: FAIL
Ran test case with proposed tomcat6-6.0.18-0ubuntu3.1: SUCCESS
Upgrade/removal/purge tests: SUCCESS

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package tomcat6 - 6.0.18-0ubuntu3.1

tomcat6 (6.0.18-0ubuntu3.1) intrepid-proposed; urgency=low

  * patches/use-commons-dbcp.patch: Change default DBCP factory class
    to org.apache.commons.dbcp.BasicDataSourceFactory (LP: #283852)
  * tomcat6.dirs, tomcat6.postinst, default_root/index.html: Create
    Catalina/localhost in /etc/tomcat6 and make it writeable by the tomcat6
    group, so that autodeploy and admin webapps work as expected (LP: #294277)

 -- Thierry Carrez <email address hidden> Fri, 05 Dec 2008 09:58:55 +0100

Changed in tomcat6:
status: Fix Committed → Fix Released
Mark Thornton (mthornton-2) wrote :

This problem has resurfaced in tomcat7 with identical symptoms. The simplest fix is to use the new tomcat connection pool.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers