Bug 819087 - tomcat-dbcp.jar is missing
Summary: tomcat-dbcp.jar is missing
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: tomcat
Version: 18
Hardware: Unspecified
OS: Linux
high
urgent
Target Milestone: ---
Assignee: Ivan Afonichev
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 916417 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-05-04 19:37 UTC by Samuel Sieb
Modified: 2013-04-25 08:47 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-04-25 08:42:32 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Samuel Sieb 2012-05-04 19:37:10 UTC
The tomcat-dbcp.jar file is missing from the tomcat package.  This means that jdbc resources don't work.  You get the following error when tomcat tries to start the app:

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 copied the jar file from the upstream zip file and now it works.

Comment 1 Ivan Afonichev 2012-05-04 20:25:52 UTC
Fedora tomcat and tomcat6 are using apache-commons-dbcp instead of tomcat-dbcp
In fact it seems that there is no tomcat code for tomcat-dbcp
Tomcat use commons-dbcp sources to build it's tomcat-dbcp
As far as I understand it's not so good behavior for fedora package.


    <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>

Comment 2 Samuel Sieb 2012-05-04 21:29:18 UTC
It turns out that that jar may be unnecessary.  It appears that the class tomcat was looking for (org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory) is some sort of default.  After discovering what I found in bug 819087, I removed tomcat-dbcp.jar and the error didn't come back.

Comment 3 Samuel Sieb 2012-05-04 21:46:57 UTC
The bug number was supposed to be bug 819112, not self-referential.  Anyways, it's still strange that an upstream file is not included, but if it's not necessary, then I guess it doesn't matter.

Comment 4 Eric Hopper 2012-06-01 22:20:20 UTC
This is a big problem for me. It's preventing me from being able to deploy Gerrit as this config totally fails to publish the appropriate JNDC resource:

    <Resource name="jdbc/ReviewDb" auth="Container"
              type="javax.sql.DataSource"
              driverClassName="org.h2.Driver"
              url="jdbc:h2:/var/opt/gerrit/db/ReviewDB"/>

And the errors point to org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory being missing. The people on #tomcat think this is a problem too.

Comment 5 Ivan Afonichev 2012-06-01 22:50:38 UTC
[van@oec-src ~]$ cat /etc/tomcat/Catalina/localhost/gerrit.xml 
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" allowCasualMultipartParsing="true" path="/gerrit">


  <Resource name="jdbc/ReviewDb" auth="Container"
                 type="javax.sql.DataSource"
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
driverClassName="org.postgresql.Driver"
                 url="jdbc:postgresql://dbhost:5432/reviewdb"
                 username="gerrit2" password="******" maxActive="20"
maxIdle="10"
                 maxWait="-1"/>
</Context>



Gerrit is working fine for me on tomcat-7.0.27-2.fc17.noarch with this context.
As far as I know including libs that are just renamed java packages of other official libs that are available as fedora packages does not meet Fedora requirements.
As workaround we can add this Resource "factory" recommendations into some readme file in package...

Comment 6 Eric Hopper 2012-06-02 01:04:02 UTC
It still doesn't work for me... in /etc/tomcat/Catalina/localhost/gerrit.xml


<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" allowCasualMultipartParsing="true" path="/gerrit">
  <Resource name="jdbc/ReviewDb" auth="Container"
            type="javax.sql.DataSource"
            factory="org.apache.commons.dbcp.BasicDataSourceFactory"
            driverClassName="org.h2.Driver"
            url="jdbc:h2:/var/opt/gerrit/db/ReviewDB"
            username="" password=""
            maxActive="20" maxIdle="10" maxWait="-1"/>
</Context>


And here is what I see in /var/log/tomcat/catalina.out:


Jun 01, 2012 6:01:03 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Jun 01, 2012 6:01:03 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 01, 2012 6:01:03 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 01, 2012 6:01:03 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 323 ms
Jun 01, 2012 6:01:03 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 01, 2012 6:01:03 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
Jun 01, 2012 6:01:03 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat/Catalina/localhost/gerrit.xml
Jun 01, 2012 6:01:05 PM org.apache.catalina.core.NamingContextListener addResource
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]

Comment 7 Philippe Banwarth 2012-09-11 15:17:45 UTC

As of tomcat 7.0.29-1fc17 it seems that declaring the factory (in the context or via JAVA_OPTS) is not sufficient. 

I had to add the commons pool library

ln -s /usr/share/java/apache-commons-pool.jar /usr/share/tomcat/lib/

Comment 8 Ivan Afonichev 2013-02-03 21:44:14 UTC
Link to /usr/share/java/apache-commons-pool.jar already exists in tomcat-lib rpm

Comment 9 Ivan Afonichev 2013-02-28 07:09:25 UTC
*** Bug 916417 has been marked as a duplicate of this bug. ***

Comment 10 Sebastien Pasche 2013-04-25 08:17:57 UTC
The bug is present again in fedora 18 :-(

There is information about my install : 

[root@mgbwimi10 lib]# rpm -q tomcat-lib
tomcat-lib-7.0.37-1.fc18.noarch
[root@mgbwimi10 lib]# pwd
/usr/share/tomcat/lib
[root@mgbwimi10 lib]# ll
total 3784
-rw-r--r--. 1 root root   15275 Feb 19 22:40 annotations-api.jar
-rw-r--r--. 1 root root   54800 Feb 19 22:40 catalina-ant.jar
-rw-r--r--. 1 root root  132510 Feb 19 22:40 catalina-ha.jar
-rw-r--r--. 1 root root 1561168 Feb 19 22:40 catalina.jar
-rw-r--r--. 1 root root  254822 Feb 19 22:40 catalina-tribes.jar
lrwxrwxrwx. 1 root root      46 Apr 24 16:46 commons-collections.jar -> /usr/share/java/apache-commons-collections.jar
lrwxrwxrwx. 1 root root      39 Apr 24 16:46 commons-dbcp.jar -> /usr/share/java/apache-commons-dbcp.jar
-rw-r--r--. 1 root root  123093 Feb 19 22:40 jasper-el.jar
-rw-r--r--. 1 root root  597932 Feb 19 22:40 jasper.jar
lrwxrwxrwx. 1 root root      23 Apr 24 16:46 jasper-jdt.jar -> /usr/share/java/ecj.jar
lrwxrwxrwx. 1 root root      25 Apr 24 16:46 log4j.jar -> /usr/share/java/log4j.jar
-rw-r--r--. 1 root root    6873 Feb 19 22:40 tomcat-api.jar
-rw-r--r--. 1 root root  774765 Feb 19 22:40 tomcat-coyote.jar
lrwxrwxrwx. 1 root root      24 Apr 24 16:46 tomcat-el-2.2-api.jar -> ../tomcat-el-2.2-api.jar
-rw-r--r--. 1 root root   77030 Feb 19 22:40 tomcat-i18n-es.jar
-rw-r--r--. 1 root root   48499 Feb 19 22:40 tomcat-i18n-fr.jar
-rw-r--r--. 1 root root   51161 Feb 19 22:40 tomcat-i18n-ja.jar
-rw-r--r--. 1 root root  123623 Feb 19 22:40 tomcat-jdbc.jar
lrwxrwxrwx. 1 root root      25 Apr 24 16:46 tomcat-jsp-2.2-api.jar -> ../tomcat-jsp-2.2-api.jar
lrwxrwxrwx. 1 root root      37 Apr 24 16:46 tomcat-juli.jar -> /usr/share/tomcat/bin/tomcat-juli.jar
lrwxrwxrwx. 1 root root      29 Apr 24 16:46 tomcat-servlet-3.0-api.jar -> ../tomcat-servlet-3.0-api.jar
-rw-r--r--. 1 root root   23086 Feb 19 22:40 tomcat-util.jar
[root@mgbwimi10 lib]#

And if I look into the src.rpm from  : http://koji.fedoraproject.org/koji/buildinfo?buildID=407381

We can see the missing link creation here : 

pushd ${RPM_BUILD_ROOT}%{libdir}
    # symlink JSP and servlet API jars
    %{__ln_s} ../%{name}-jsp-%{jspspec}-api.jar .
    %{__ln_s} ../%{name}-servlet-%{servletspec}-api.jar .
    %{__ln_s} ../%{name}-el-%{elspec}-api.jar .
    %{__ln_s} $(build-classpath apache-commons-collections) commons-collections.jar
    %{__ln_s} $(build-classpath apache-commons-dbcp) commons-dbcp.jar
    %{__ln_s} $(build-classpath log4j) log4j.jar
    %{__ln_s} $(build-classpath ecj) jasper-jdt.jar

    # Temporary copy the juli jar here from /usr/share/java/tomcat (for maven depmap)
    %{__cp} -a ${RPM_BUILD_ROOT}%{bindir}/tomcat-juli.jar ./
popd

There is no link creation for apache-commons-pool


Should look like : 

%{__ln_s} $(build-classpath apache-commons-pool) commons-pool.jar

Comment 11 Sebastien Pasche 2013-04-25 08:42:32 UTC
creating a new bug with this issue

Comment 12 Sebastien Pasche 2013-04-25 08:47:23 UTC
https://bugzilla.redhat.com/show_bug.cgi?id=956569


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