Red Hat Bugzilla – Bug 1240279
The command tomcat-digest doesn't work with RHEL 7
Last modified: 2016-11-03 17:09:08 EDT
Description of problem: 1. When using cmd "tomcat-digest" in order to create a SHA hash of tomcat passwords,the cmd fails with below java exception. ~~~ Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tomcat/util/ExceptionUtils at org.apache.catalina.startup.Tool.main(Tool.java:230) Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.ExceptionUtils at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 1 more ~~~ Version-Release number of selected component (if applicable): ~~~ Server version: Apache Tomcat/7.0.54 Server built: Mar 24 2015 07:49:05 Server number: 7.0.54.0 OS Name: Linux OS Version: 3.10.0-229.el7.x86_64 Architecture: amd64 ~~~ How reproducible: 1. [pankaj@dhcp Desktop]tomcat-digest (Use simple cmd with no parameter) Actual results: ~~~ Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tomcat/util/ExceptionUtils at org.apache.catalina.startup.Tool.main(Tool.java:230) Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.ExceptionUtils at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 1 more ~~~ Expected results: ~~~ [pankaj@dhcp Desktop]$ tomcat-digest -a SHA-256 Foo Foo:1cbec737f863e4922cee63cc2ebbfaafcd1cff8b790d8cfd2e6a5d550b648afa ~~~ Additional info: - It can be seen that the cause of error is due to the class "org.apache.tomcat.util.ExceptionUtils" is not available for the class loader during this early stage.The class "org.apache.tomcat.util.ExceptionUtils" is located in "/usr/share/tomcat/lib/tomcat-coyote.jar" ~~~~~~~~~ [pankaj@dhcp233-125 lib]egrep -ir "org.apache.tomcat.util.ExceptionUtils" /usr/share/tomcat/lib/ O/P : Binary file /usr/share/tomcat/lib/tomcat-coyote.jar matches ~~~~~~~~~ - We also need to add "/usr/share/tomcat/lib/tomcat-util.jar" to classpath or else the cmd will throw the error something like : ~~~ java.lang.NoClassDefFoundError: org/apache/tomcat/util/res/StringManager at org.apache.catalina.util.LifecycleBase.<clinit>(LifecycleBase.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.catalina.startup.Tool.main(Tool.java:228) Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.res.StringManager ~~~ Workaround : - The simple workaround is just add the jar's "tomcat-util.jar" and "tomcat-coyote.jar" to his classpath. eg : # CLASSPATH=/usr/share/tomcat/lib/tomcat-util.jar:/usr/share/tomcat/lib/tomcat-coyote.jar tomcat-digest -a md5 mycredentials - The result would be it includes the missing .jar files needed by tomcat-digest.After adding these jar's the script works as expected.
Dear Filip, could you try to reproduce it with our JWS3 RHEL7 RPM and ZIP distro?
The workaround is the fix and matches (mostly) what was done for JWS-232 :) Patch: # diff -rupN /usr/bin/tomcat-digest.orig /usr/bin/tomcat-digest --- /usr/bin/tomcat-digest.orig 2015-11-10 14:53:54.682000000 -0500 +++ /usr/bin/tomcat-digest 2015-11-10 14:52:53.539000000 -0500 @@ -34,7 +34,7 @@ export CLASSPATH MAIN_CLASS="org.apache.catalina.startup.Tool" BASE_FLAGS="-Dcatalina.home=\"$CATALINA_HOME\"" BASE_OPTIONS="" -BASE_JARS="commons-daemon tomcat/catalina servlet" +BASE_JARS="commons-daemon tomcat/catalina servlet tomcat/tomcat-util tomcat/tomcat-coyote" # Set parameters set_classpath $BASE_JARS Test: # tomcat-digest -a md5 test test:098f6bcd4621d373cade4e832627b4f6
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2016-2599.html