Bug 689924 - tomcat5 NullPointerException on start
tomcat5 NullPointerException on start
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: tomcat5 (Show other bugs)
5.5.z
x86_64 Linux
urgent Severity urgent
: rc
: ---
Assigned To: David Knox
tomcat-qe
: Regression, ZStream
Depends On:
Blocks: 717457
  Show dependency treegraph
 
Reported: 2011-03-22 15:44 EDT by Paul Donohue
Modified: 2015-11-01 19:16 EST (History)
9 users (show)

See Also:
Fixed In Version: tomcat5-5.5.23-0jpp.19.el5 tomcat5-5.5.23-0jpp.18.el5_6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-01-08 02:06:26 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Legacy) 58761 None None None Never

  None (edit)
Description Paul Donohue 2011-03-22 15:44:45 EDT
The fix to bug #623465 (released in tomcat5-5.5.23-0jpp.16.el5) introduced another bug that causes a similar NullPointerException on start-up for any context.xml files that do not specify a docBase:

Mar 22, 2011 3:00:04 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
LifecycleException:  Error initializaing :  java.lang.NullPointerException
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3986)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:634)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:561)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:496)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1193)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:448)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Mar 22, 2011 3:00:04 PM org.apache.catalina.startup.HostConfig deployDescriptor
SEVERE: Error deploying configuration descriptor probe.xml
java.lang.IllegalStateException: ContainerBase.addChild: start: LifecycleException:  Error initializaing :  java.lang.NullPointerException
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:764)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:634)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:561)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:496)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1193)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:448)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

The problem appears to be on line 837 of container/catalina/src/share/org/apache/catalina/startup/ContextConfig.java, which is added to that file by tomcat5-5.5.23-CVE-2009-2693-2901-2902.patch:
if (docBase == null) {
...
    if (docBase.equals("")) {

The second if statement should be:
    if (pathName.equals("")) {

I have tested this fix in my local environment, and it seems to solve the problem.
Comment 1 David Knox 2011-05-18 11:39:10 EDT
This bz is for the rhel-5 tomcat5 zstream 5.5.z but the cited nvr is not. I made the change in RHEL-5 (tomcat5-5.5.23-0jpp.19.el5). Because this affects a CVE patch, I fixed this in RHEL-5_6-Z (tomcat5-5.5.23-0jpp.18.el5_6) as well.


-            if (path.equals("")) {
+            if (docBase.equals("")) {
                 docBase = "ROOT";
             } else {
-                if (path.startsWith("/")) {
-                    docBase = path.substring(1);
+                if (pathName.equals("")) {
+                    docBase = path.substring(1);
                 } else {
-                    docBase = path;
+                    docBase = pathName;
Comment 4 David Knox 2011-05-24 11:31:00 EDT
Tested successfully on rhel-5.5. with scratch build with the following correction to the patch:
-            if (path.equals("")) {
+            if (docBase.equals("")) {
                 docBase = "ROOT";
             } else {
-                if (path.startsWith("/")) {
-                    docBase = path.substring(1);
+                if (pathName.equals("")) {
+                    docBase = "/";
                 } else {
-                    docBase = path;
+                    docBase = pathName;
                 }
             }

This fix is in tomcat5-5.5.23-0jpp.19.el5.src.rpm.
The same fix is being ported to 5-5-z

catalina.out:
[root@dell-pe800-01 ~]# cat /var/log/tomcat5/catalina.out 
Using CATALINA_BASE:   /usr/share/tomcat5
Using CATALINA_HOME:   /usr/share/tomcat5
Using CATALINA_TMPDIR: /usr/share/tomcat5/temp
Using JRE_HOME:       
May 24, 2011 11:16:28 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
May 24, 2011 11:16:28 AM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
May 24, 2011 11:16:28 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1041 ms
May 24, 2011 11:16:28 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
May 24, 2011 11:16:28 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.23
May 24, 2011 11:16:28 AM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
May 24, 2011 11:16:30 AM org.apache.catalina.core.ApplicationContext log
INFO: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]]
May 24, 2011 11:16:30 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
May 24, 2011 11:16:30 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
May 24, 2011 11:16:31 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
May 24, 2011 11:16:31 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
May 24, 2011 11:16:31 AM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 24, 2011 11:16:31 AM org.apache.catalina.connector.MapperListener init
INFO: Registering Hosts
May 24, 2011 11:16:31 AM org.apache.catalina.connector.MapperListener init
INFO: Registering WebModule Contexts
May 24, 2011 11:16:31 AM org.apache.catalina.connector.MapperListener init
INFO: Registering Servlets
May 24, 2011 11:16:31 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
May 24, 2011 11:16:31 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16  config=null
May 24, 2011 11:16:31 AM org.apache.catalina.connector.MapperListener init
INFO: Registering Hosts
May 24, 2011 11:16:31 AM org.apache.catalina.connector.MapperListener init
INFO: Registering WebModule Contexts
May 24, 2011 11:16:31 AM org.apache.catalina.connector.MapperListener init
INFO: Registering Servlets
May 24, 2011 11:16:31 AM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
May 24, 2011 11:16:31 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3389 ms

[root@dell-pe800-01 ~]# wget http://localhost:8080/
--2011-05-24 11:17:07--  http://localhost:8080/
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7914 (7.7K) [text/html]
Saving to: `index.html'

100%[======================================>] 7,914       --.-K/s   in 0s      

2011-05-24 11:17:07 (260 MB/s) - `index.html' saved [7914/7914]
Comment 15 Aldrey Galindo 2011-06-01 20:24:01 EDT
Which has tomcat5-5.5.23-0jpp.19.el5.src.rpm?
Comment 16 Niels de Vos 2011-06-06 06:54:29 EDT
Hello Aldrey,

tomcat5-5.5.23-0jpp.19.el5 has not been released yet. Please open a support case in the Customer Portal (https://access.redhat.com/) so that Red Hat Support can follow up with you.

Thanks,
Niels
Comment 35 Michal Haško 2012-02-01 08:25:05 EST
reproduced on tomcat5-5.5.23-0jpp.16.el5:
  https://beaker.engineering.redhat.com/jobs/187858
VERIFIED on tomcat5-5.5.23-0jpp.22.el5_7
  https://beaker.engineering.redhat.com/jobs/187885
Comment 40 errata-xmlrpc 2013-01-08 02:06:26 EST
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.

http://rhn.redhat.com/errata/RHBA-2013-0014.html

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