Hi, Asiri.
The problem is Execution object is not completely initialized so it has
no ExecutionContext.
AFAIK, Execution need to be initialized explicitly by
ServletContainerInitializer or else.
Look at XWikiAction#initializeContainerComponent
So you need something similar before call XWiki.getXWiki(xwikiContext);
Asiri Rathnayake wrote:
Hi Devs,
Currently I have my pom file as bellow,
<....>
.....
<dependency>
<groupId>com.xpn.xwiki.platform</groupId>
<artifactId>*xwiki-core*</artifactId>
<version>*1.5-milestone-2*</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>*xwiki-core-plexus*</artifactId>
<version>*1.5-SNAPSHOT*</version>
</dependency>
.....
</...>
And everything is working fine :)
But when i upgraded the pom file to use 1.6-SNAPSHOT versions of above
dependencies as bellow,
<....>
.....
<dependency>
<groupId>com.xpn.xwiki.platform</groupId>
<artifactId>*xwiki-core*</artifactId>
<version>*1.6-SNAPSHOT*</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>*xwiki-core-plexus*</artifactId>
<version>*1.6-SNAPSHOT*</version>
</dependency>
.....
</...>
I get the follwing exception when trying to access the xwiki-webdav servlet,
<dump>
[INFO] Started Jetty Server
java.lang.NullPointerException
at
org.xwiki.context.DefaultExecution.getContext(DefaultExecution.java:50)
at
com.xpn.xwiki.store.XWikiHibernateBaseStore.initialize(XWikiHibernateBaseStore.java:90)
at
org.xwiki.plexus.lifecycle.phase.InitializePhase.execute(InitializePhase.java:37)
at
org.codehaus.plexus.lifecycle.AbstractLifecycleHandler.start(AbstractLifecycleHandler.java:128)
at
org.codehaus.plexus.component.manager.AbstractComponentManager.startComponentLifecycle(AbstractComponentManager.java:142)
at
org.codehaus.plexus.component.manager.AbstractComponentManager.createComponentInstance(AbstractComponentManager.java:132)
at
org.codehaus.plexus.component.manager.ClassicSingletonComponentManager.getComponent(ClassicSingletonComponentManager.java:90)
at
org.codehaus.plexus.DefaultComponentLookupManager.lookup(DefaultComponentLookupManager.java:147)
at
org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:277)
at
org.codehaus.plexus.personality.plexus.lifecycle.phase.PlexusContainerLocator.lookup(PlexusContainerLocator.java:51)
at
org.xwiki.plexus.manager.PlexusComponentManager.lookup(PlexusComponentManager.java:56)
at com.xpn.xwiki.web.Utils.getComponent(Utils.java:548)
at com.xpn.xwiki.XWiki.initXWiki(XWiki.java:668)
at com.xpn.xwiki.XWiki.<init>(XWiki.java:650)
at com.xpn.xwiki.XWiki.getMainXWiki(XWiki.java:310)
at com.xpn.xwiki.XWiki.getXWiki(XWiki.java:381)
at
com.xpn.xwiki.plugin.webdav.utils.XWikiDavParams.initXWikiContext(XWikiDavParams.java:99)
at
com.xpn.xwiki.plugin.webdav.utils.XWikiDavParams.<init>(XWikiDavParams.java:62)
at
com.xpn.xwiki.plugin.webdav.utils.XWikiResourceFactory.createResource(XWikiResourceFactory.java:97)
at
com.xpn.xwiki.plugin.webdav.utils.XWikiResourceFactory.createResource(XWikiResourceFactory.java:66)
at
com.xpn.xwiki.plugin.webdav.XWikiDavServlet.service(XWikiDavServlet.java:357)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:363)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:219)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:738)
at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:113)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:325)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:873)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:391)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
</dump>
Bellow is the way i initialize the xwiki context,
<code>
private void initXWikiContext(DavServletRequest drequest, DavServletResponse
dresponse, ServletContext servletContext) throws XWikiException
{
if (this.xwikiEngine == null) {
xwikiEngine = new XWikiServletContext(servletContext);
}
xwikiRequest = (this.xwikiRequest != null) ? this.xwikiRequest :
new XWikiServletRequest(drequest);
xwikiResponse = (this.xwikiResponse != null) ? this.xwikiResponse :
new XWikiXMLRPCResponse(dresponse);
xwikiContext = Utils.prepareContext("", xwikiRequest, xwikiResponse,
xwikiEngine);
xwikiContext.setMode(XWikiContext.MODE_GWT);
xwikiContext.setDatabase("xwiki");
* XWiki xwiki = XWiki.getXWiki(xwikiContext);
* ...............
}*
*</code>
The line "*XWiki xwiki = XWiki.getXWiki(xwikiContext);*" is where the
exception gets thrown.
Can any of you please help me fix this ? It would be a big help :)
Thanks a lot.
--
Artem Melentyev