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.)
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>
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
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.
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. ;-)
Proposed solution: to add -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory to JAVA_OPTS
tomcat-7.0.68-2.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-b19c75d748
tomcat-8.0.32-4.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-a266936df7
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
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
tomcat-7.0.68-3.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-e6651efbaf
tomcat-8.0.32-5.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-48ee453d15
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
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
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.
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.