Bug 1214381 - tomcat lib package doesn't include tomcat-dbcp.jar (which is required and different from apache-commons-dbcp)
Summary: tomcat lib package doesn't include tomcat-dbcp.jar (which is required and dif...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: tomcat
Version: epel7
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Ivan Afonichev
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-22 15:10 UTC by Woonsan
Modified: 2016-03-25 22:22 UTC (History)
3 users (show)

Fixed In Version: tomcat-8.0.32-5.fc23 tomcat-7.0.68-3.fc22
Clone Of:
Environment:
Last Closed: 2016-03-25 01:26:54 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Woonsan 2015-04-22 15:10:49 UTC
Description of problem:


Version-Release number of selected component (if applicable):
- tomcat-7.0.59-1.fc21

How reproducible:
- If you install it, you won't see ${catalina.home}/lib/tomcat-dbcp.jar.

Steps to Reproduce:
1. Install tomcat with it.
2. Check if tomcat-dbcp.jar exists under ${catalina.home}/lib/.

Actual results:
- Because tomcat-dbcp.jar is missing, if you define a JNDI DataSource in context.xml file (in either $CATALINA_BASE/conf/ or war) [1], tomcat fails to initialize DataSource, leaving the following logs:

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]

Please note that tomcat-dbcp.jar from the ASF official release contains the org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory class, not in commons-dbcp.jar.

[1] https://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html

Expected results:
- It shouldn't meet ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory while initializing DataSource resource.

Additional info:
- http://stackoverflow.com/a/25941303
  (this problem was shared in StackOverFlow already long time ago.)

Comment 1 Ivan Afonichev 2015-04-22 20:45:54 UTC
There is org.apache.commons.BasicDataSourceFactory class in apache-commons-dbcp-1.4-16.fc21.noarch


Here is the only thing tomcat build script is doing to build "tomcat"-dbcp:


  <target name="build-tomcat-dbcp" depends="build-manifests" unless="no.build.dbcp">
    <copy todir="${tomcat-dbcp.home}">
      <fileset dir="${commons-pool.home}">
        <include name="**/*.java" />
        <exclude name="**/test/**" />
      </fileset>
      <fileset dir="${commons-dbcp.home}">
        <include name="**/*.java" />
        <exclude name="**/test/**" />
        <exclude name="**/managed/**" />
      </fileset>
    </copy>
    <replace dir="${tomcat-dbcp.home}/src/java/org/apache/commons"
        encoding="ISO-8859-1">
      <replacefilter token="org.apache.commons"
            value="org.apache.tomcat.dbcp" />
    </replace>
    <replace dir="${tomcat-dbcp.home}/src/java/org/apache/commons/pool/impl"
        encoding="ISO-8859-1">
      <replacefilter token="enum"
            value="enumeration" />
    </replace>

    <mkdir dir="${tomcat-dbcp.home}/src/java/org/apache/tomcat/dbcp" />
    <move todir="${tomcat-dbcp.home}/src/java/org/apache/tomcat/dbcp">
      <fileset dir="${tomcat-dbcp.home}/src/java/org/apache/commons" />
    </move>
    <mkdir dir="${tomcat-dbcp.home}/classes"/>
    <javac destdir="${tomcat-dbcp.home}/classes"
           debug="${compile.debug}"
           deprecation="${compile.deprecation}"
           source="${compile.source}"
           target="${compile.target}"
           sourcepath="${tomcat-dbcp.home}/src/java"
           srcdir="${tomcat-dbcp.home}/src/java"
           encoding="ISO-8859-1"
           includeantruntime="false">
      <include name="**" />
    </javac>
    <jarIt jarfile="${tomcat-dbcp.jar}"
      filesDir="${tomcat-dbcp.home}/classes"
      filesId="files.tomcat-dbcp" />
    <jarIt jarfile="${tomcat-dbcp-src.jar}"
      filesDir="${tomcat-dbcp.home}/src/java"
      filesId="files.tomcat-dbcp" />
  </target>

Comment 2 Woonsan 2015-04-22 21:28:46 UTC
Hi Ivan,

There are two BasicDataSourceFactory FQCNs here:
- org.apache.commons.BasicDataSourceFactory
- org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory

You can see the first one existing in apache-commons-dbcp jar, but Tomcat replaces apache-commons-dbcp jar with its own custom jar file, tomcat-dbcp jar where you can find the second one.

If you see the ant tasks carefully, then you will see it's doing the following:
- copy apache-commons-dbcp source to a directory
- change all the package string in each .java source from 'org.apache.commons' to 'org.apache.tomcat.dbcp'.
- build and package it to tomcat-dbcp jar

Tomcat uses org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory instead of org.apache.commons.BasicDataSourceFactory for some reason.

Therefore, if you do not package the tomcat-dbcp jar as provided by tomcat project, then it would never work in database integrated web application use case scenarios with the current tomcat package.

Regards,

Woonsan

Comment 3 Ivan Afonichev 2016-02-11 13:52:55 UTC
Tomcat works briliantly with 
factory="org.apache.commons.dbcp.BasicDataSourceFactory"


<Resource name="jdbc/ReviewDb" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               factory="org.apache.commons.dbcp.BasicDataSourceFactory"
               username="gerrit2" password="paasword" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3306/reviewdb"/>



Maybe we'll add patch to change default factory package to common one.

Comment 4 Woonsan 2016-02-11 15:38:50 UTC
If you mean to post a patch in tomcat project to use commons-dbcp jar directly, that sounds right to me. I have wondered why tomcat initially had to build a custom commons-dbcp jar, but I guess you will get an answer if someone there doesn't want to use commons-dbcp jar directly. ;-)

Comment 5 Ivan Afonichev 2016-02-25 14:05:12 UTC
Proposed solution: to add -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory to JAVA_OPTS

Comment 6 Fedora Update System 2016-02-27 15:43:11 UTC
tomcat-7.0.68-2.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-b19c75d748

Comment 7 Fedora Update System 2016-02-27 15:43:12 UTC
tomcat-8.0.32-4.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-a266936df7

Comment 8 Fedora Update System 2016-02-28 13:50:46 UTC
tomcat-7.0.68-2.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-b19c75d748

Comment 9 Fedora Update System 2016-02-28 13:53:40 UTC
tomcat-8.0.32-4.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-a266936df7

Comment 10 Fedora Update System 2016-03-11 06:48:59 UTC
tomcat-7.0.68-3.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-e6651efbaf

Comment 11 Fedora Update System 2016-03-11 06:49:55 UTC
tomcat-8.0.32-5.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-48ee453d15

Comment 12 Fedora Update System 2016-03-12 16:53:14 UTC
tomcat-7.0.68-3.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-e6651efbaf

Comment 13 Fedora Update System 2016-03-12 17:25:20 UTC
tomcat-8.0.32-5.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-48ee453d15

Comment 14 Fedora Update System 2016-03-25 01:26:38 UTC
tomcat-8.0.32-5.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2016-03-25 22:21:22 UTC
tomcat-7.0.68-3.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.