I've implemented the simplest EventListener possible by just implementing the
EventListener required methods, adding an @Component("mystartup") line and
adding my class to components.txt.
However, on startup I get an error Failed to lookup component [role =
[org.xwiki.observation.ObservationManager] hint = [default]]
What am I missing? Is this a chicken and egg problem?
@Component("mystartup")
public class MyStartup implements EventListener {
public List<Event> getEvents() {
return Arrays.asList(new ApplicationStartedEvent(), new
ApplicationStoppedEvent());
}
public String getName() {
return "mystartup";
}
public void onEvent(Event arg0, Object arg1, Object arg2) {
// TODO Auto-generated method stub
}
java.lang.RuntimeException: Failed to find the Observation Manager component
at
org.xwiki.container.servlet.XWikiServletContextListener.contextInitialized(XWikiServletContextListener.java:79)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1239)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:466)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at
org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at
org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mortbay.start.Main.invokeMain(Main.java:194)
at org.mortbay.start.Main.start(Main.java:523)
at org.mortbay.start.Main.main(Main.java:119)
Caused by: org.xwiki.component.manager.ComponentLookupException: Failed to lookup
component [role = [org.xwiki.observation.ObservationManager] hint = [default]]
at
org.xwiki.component.embed.EmbeddableComponentManager.initialize(EmbeddableComponentManager.java:263)
at
org.xwiki.component.embed.EmbeddableComponentManager.lookup(EmbeddableComponentManager.java:93)
at
org.xwiki.container.servlet.XWikiServletContextListener.contextInitialized(XWikiServletContextListener.java:76)
... 22 more
Caused by: java.lang.NullPointerException
at
org.xwiki.observation.internal.DefaultObservationManager.addListener(DefaultObservationManager.java:157)
at
org.xwiki.observation.internal.DefaultObservationManager.initialize(DefaultObservationManager.java:128)
at
org.xwiki.component.embed.EmbeddableComponentManager.createInstance(EmbeddableComponentManager.java:328)
at
org.xwiki.component.embed.EmbeddableComponentManager.initialize(EmbeddableComponentManager.java:254)
... 24 more