DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20987>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20987
uninitialized ComponentLocator warnings on startup
Summary: uninitialized ComponentLocator warnings on startup
Product: Cocoon 2
Version: Current CVS 2.1
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: core
AssignedTo: cocoon-dev@xml.apache.org
ReportedBy: jefft@apache.org
Hi,
With CVS Cocoon, I've been getting warnings like this in my error log:
WARN (2003-06-21) 19:45.39:446 [sitemap] (/fs/skin/page.css)
HttpProcessor[8787][4]/ExcaliburComponentManager: Looking up component on an
uninitialized ComponentLocator [org.apache.cocoon.generation.GeneratorSelector]
WARN (2003-06-21) 19:45.39:450 [sitemap] (/fs/skin/page.css)
HttpProcessor[8787][4]/ExcaliburComponentManager: Looking up component on an
uninitialized ComponentLocator
[org.apache.cocoon.serialization.SerializerSelector]
WARN (2003-06-21) 19:45.39:483 [sitemap] (/fs/skin/page.css)
HttpProcessor[8787][4]/ExcaliburComponentManager: Looking up component on an
uninitialized ComponentLocator
[org.apache.cocoon.transformation.TransformerSelector]
The same problem can be seen in Cocoon's logs, if the log level is taken
from from ERROR to WARN.
I eventually obtained the following stack trace snippet, illustrating
what's happening:
java.lang.RuntimeException: Looking up component on an uninitialized
ComponentLocator [org.apache.cocoon.generation.GeneratorSelector]
at
org.apache.avalon.excalibur.component.ExcaliburComponentManager.lookup(ExcaliburComponentManager.java:194)
at
org.apache.cocoon.components.CocoonComponentManager.lookup(CocoonComponentManager.java:294)
at
org.apache.cocoon.components.CocoonComponentManager.addComponent(CocoonComponentManager.java:477)
at
org.apache.avalon.excalibur.component.ExcaliburComponentManager.configure(ExcaliburComponentManager.java:477)
at
org.apache.cocoon.components.LifecycleHelper.setupComponent(LifecycleHelper.java:262)
at
org.apache.cocoon.components.LifecycleHelper.setupComponent(LifecycleHelper.java:188)
at
org.apache.cocoon.components.treeprocessor.sitemap.SitemapLanguage.createComponentManager(SitemapLanguage.java:104)
...
Here, LifecycleHelper is busy setting up a CocoonComponentManager object. It
calls ECM.configure(...), which delegates to addComponent() to add each
component in the Configuration. CocoonComponentManager overrides
addComponent() in order to tell ParentAware components about their parent:
public void addComponent(String role, Class clazz, Configuration conf)
throws ComponentException {
super.addComponent(role, clazz, conf);
if ( ParentAware.class.isAssignableFrom( clazz ) ) {
if ( parentManager != null && parentManager.hasComponent( role ) ) {
// lookup new component
Component component = null;
try {
component = this.lookup( role );
((ParentAware)component).setParentLocator( new
ComponentLocatorImpl(this.parentManager, role ));
} catch (ComponentException ignore) {
// we don't set the parent then
} finally {
this.release( component );
}
}
}
}
The problem with this is that we're technically still inside the
configure() method, and can't do a this.lookup() call, because we're not
yet initialized (configure() is called before initialize(); see [1]).
The fix is to just record each ParentAware component we encounter, and
tell it about its parent in an overridden initialize() method.
--Jeff
[1] http://avalon.apache.org/framework/reference-the-lifecycle.html