Bug 29688 - HostConfig NullPointerException
Summary: HostConfig NullPointerException
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.0.25
Hardware: All All
: P1 critical with 1 vote (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 30249 30331 30462 30899 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-06-19 13:25 UTC by Sascha Dierkes
Modified: 2004-11-16 19:05 UTC (History)
4 users (show)



Attachments
HostConfig (2.88 KB, patch)
2004-06-25 16:47 UTC, Peter Rossbach
Details | Diff
HostConfig with NPE und XML.mkdirs Patch (16.43 KB, application/octet-stream)
2004-07-05 09:34 UTC, Peter Rossbach
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sascha Dierkes 2004-06-19 13:25:36 UTC
The following Exception was thrown:

java.lang.NullPointerException
        at org.apache.catalina.startup.HostConfig.deployDescriptors
(HostConfig.java:490)    

A first analyse of source code:

    protected void deployDescriptors(File configBase, String[] files)

the "files[]" parameter might be null, but is not tested on null in body of 
method. The calling functions also don't check for a null array. Simple 
solution would be:

use:

    protected void deployDescriptors(File configBase, String[] files) {

        if (!deployXML || files==null)
           return;
        [...]

instead of:

    protected void deployDescriptors(File configBase, String[] files) {

        if (!deployXML)
           return;
        [...]

In all cases i found the calling methods use the File.list() mtehod to create 
array without check, but according to J2SE API Doc "null" is allowed as return 
value of "list()", so a check might make sense.
Comment 1 Sascha Dierkes 2004-06-23 08:57:38 UTC
After taking a deeper look into source code, there are several more points 
where the files list is not checked against null values.
Comment 2 Sascha Dierkes 2004-06-25 08:15:18 UTC
The NPE is actually blocking the whole Tomcat, because of infinite number of 
exceptions (s. log). So could someone please commit the patch I provided 
earlier. It's just simple null value checking.

Thanks,
 Sascha

from LOG:

25.06.2004 10:06:58 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor 
processChildren
SCHWERWIEGEND: Exception invoking periodic operation:
java.lang.NullPointerException
        at org.apache.catalina.startup.HostConfig.deployDescriptors
(HostConfig.java:445)
        at org.apache.catalina.startup.HostConfig.deployApps
(HostConfig.java:427)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1064)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent
(HostConfig.java:327)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent
(LifecycleSupport.java:119)
        at org.apache.catalina.core.StandardHost.backgroundProcess
(StandardHost.java:800)
        at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChild
ren(ContainerBase.java:1619)
        at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChild
ren(ContainerBase.java:1628)
        at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run
(ContainerBase.java:1608)
        at java.lang.Thread.run(Thread.java:534)
25.06.2004 10:06:58 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor 
processChildren
SCHWERWIEGEND: Exception invoking periodic operation:
java.lang.NullPointerException
        at org.apache.catalina.startup.HostConfig.deployDescriptors
(HostConfig.java:445)
        at org.apache.catalina.startup.HostConfig.deployApps
(HostConfig.java:427)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1064)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent
(HostConfig.java:327)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent
(LifecycleSupport.java:119)
        at org.apache.catalina.core.StandardHost.backgroundProcess
(StandardHost.java:800)
        at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChild
ren(ContainerBase.java:1619)
        at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChild
ren(ContainerBase.java:1628)
        at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run
(ContainerBase.java:1608)
        at java.lang.Thread.run(Thread.java:534)
25.06.2004 10:06:58 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor 
processChildren
SCHWERWIEGEND: Exception invoking periodic operation:
java.lang.NullPointerException
        at org.apache.catalina.startup.HostConfig.deployDescriptors
(HostConfig.java:445)
        at org.apache.catalina.startup.HostConfig.deployApps
(HostConfig.java:427)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1064)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent
(HostConfig.java:327)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent
(LifecycleSupport.java:119)
        at org.apache.catalina.core.StandardHost.backgroundProcess
(StandardHost.java:800)
        at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChild
ren(ContainerBase.java:1619)
        at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChild
ren(ContainerBase.java:1628)
        at 
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run
(ContainerBase.java:1608)
        at java.lang.Thread.run(Thread.java:534)
i
Comment 3 Peter Rossbach 2004-06-25 16:47:16 UTC
Hey,

I have made a patch to fix some NPE risks.

also this patch include the xml.mkdir fix.
http://issues.apache.org/bugzilla/show_bug.cgi?id=29038

regards
peter
Comment 4 Peter Rossbach 2004-06-25 16:47:48 UTC
Created attachment 11947 [details]
HostConfig
Comment 5 Sascha Dierkes 2004-07-05 08:59:26 UTC
As mentioned before the NPE is blocking the tomcat, it's even impossible to 
shut down the server:

Catalina.stop: java.net.SocketException: Broken pipe
java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:414)
        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:324)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:333)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:424)

The server shuts down normally if the NPE is not in the log-file, whenever the 
NPE is in the logs, the shutdown script failed with above exception (no need to 
tell me something about killing processes). I would really appreciate if the 
patch could be applied and committed.  Any reason why this didn't happen ? If 
there are any concerns, could you please tell me ?

-Sascha
Comment 6 Peter Rossbach 2004-07-05 09:33:33 UTC
Hey,

here my HostConfig.class.

copy to server/classes/org/apache/catalina/startup

regards
peter
Comment 7 Peter Rossbach 2004-07-05 09:34:37 UTC
Created attachment 12026 [details]
HostConfig with NPE und XML.mkdirs Patch
Comment 8 Yoav Shapira 2004-07-27 17:01:12 UTC
*** Bug 30331 has been marked as a duplicate of this bug. ***
Comment 9 Yoav Shapira 2004-07-28 16:08:16 UTC
*** Bug 30249 has been marked as a duplicate of this bug. ***
Comment 10 Yoav Shapira 2004-08-04 14:38:48 UTC
*** Bug 30462 has been marked as a duplicate of this bug. ***
Comment 11 Yoav Shapira 2004-08-21 19:20:34 UTC
Patch applied in TOMCAT_5_0 branch as suggested here.  Modified portions 
applied on CVS HEAD as HostConfig on HEAD has already been significantly 
modified for Tomcat 5.5.
Comment 12 Yoav Shapira 2004-08-27 16:38:27 UTC
*** Bug 30899 has been marked as a duplicate of this bug. ***