You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Vadim Gritsenko <va...@reverycodes.com> on 2004/05/17 15:08:39 UTC

NPE on shutdown

Yep, again this same ol' NPE from SourceResolver:

WARN    (2004-05-17) 08:56.47:010   [core.manager] (Unknown-URI) 
Unknown-thread/ThreadSafeComponentHandler: Error decommissioning 
component: org.apache.cocoon.components.treeprocessor.TreeProcessor
java.lang.NullPointerException
    at 
org.apache.excalibur.source.impl.SourceResolverImpl.release(SourceResolverImpl.java:285)
    at 
org.apache.cocoon.components.CocoonComponentManager.release(CocoonComponentManager.java:507)
    at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.dispose(TreeProcessor.java:514)
    at 
org.apache.avalon.framework.container.ContainerUtil.dispose(ContainerUtil.java:345)
    at 
org.apache.avalon.excalibur.component.DefaultComponentFactory.decommission(DefaultComponentFactory.java:336)
    at 
org.apache.avalon.excalibur.component.ThreadSafeComponentHandler.dispose(ThreadSafeComponentHandler.java:165)
    at 
org.apache.avalon.excalibur.component.ExcaliburComponentManager.dispose(ExcaliburComponentManager.java:621)
    at 
org.apache.cocoon.components.CocoonComponentManager.dispose(CocoonComponentManager.java:468)
    at 
org.apache.avalon.framework.container.ContainerUtil.dispose(ContainerUtil.java:345)
    at org.apache.cocoon.Cocoon.dispose(Cocoon.java:499)
...


And, looking at the source of CocoonComponentManager, seems it had one 
workaround for it, which does not work (at least to the extent needed) now:

    public void dispose() {
        if(getLogger().isDebugEnabled()) {
            getLogger().debug("CocoonComponentManager.dispose() called");
        }

        if ( null != this.sourceResolver ) {
            super.release( this.sourceResolver );
            // We cannot null out sourceResolver here yet as some other not
            // disposed yet components might still have unreleased sources,
            // and they will call {@link #release(Source)} during their
            // dispose().
        }
       
        super.dispose();
       
        // All components now are released so sourceResolver should be not
        // needed anymore.
        this.sourceResolver = null;

        // This is used to track bug 27249
        this.wasDisposed = true;
    }


I've got two options now...
1) Hack Excalibur... Not sure yet why it's failing, have not seen source 
yet.
2) Hack CocoonComponentManager... Add catch for NPE and log ERROR or 
WARN - this is another work around, but at least it will not interrupt 
dispose() of the component who called release().


PS This is Cocoon samples webapp

Vadim


Re: NPE on shutdown

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Unico Hommes wrote:

>Vadim Gritsenko <vadim <at> reverycodes.com> writes:
>
>  
>
>>Yep, again this same ol' NPE from SourceResolver:
>>
>>    
>>
>
><snip/>
>
>This is probably due to the fact that SourceResolver was disposed before
>TreeProcessor. Every once in a while we run into this limitation that ECM does
>not support any type of dependency management and shutdown order control.
> 
>I'd swallow the NPE in TreeProcessor since the contract in ECM seems to be that
>dependent components might already have been disposed of.
>  
>

Why in tree processor and not in CocoonComponentManager itself? 
Otherwise, you'd end up with hunting down all manager.release() 
statements and wrapping them in the try/catch block - otherwise you 
can't be sure will release() work or throw an exception.

Vadim


Re: NPE on shutdown

Posted by Unico Hommes <un...@hippo.nl>.
Vadim Gritsenko <vadim <at> reverycodes.com> writes:

> 
> Yep, again this same ol' NPE from SourceResolver:
> 

<snip/>

This is probably due to the fact that SourceResolver was disposed before
TreeProcessor. Every once in a while we run into this limitation that ECM does
not support any type of dependency management and shutdown order control.
 
I'd swallow the NPE in TreeProcessor since the contract in ECM seems to be that
dependent components might already have been disposed of.

--
Unico