org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getExternalURL' in class com.xpn.xwiki.api.Document threw exception java.lang.NullPointerException @ XWiki.WatchListMessage[33,138]

XWiki.org JIRA | Dave Mangot | 8 years ago
  1. 0

    We recently upgraded to 1.8.1 and one of my users reported this bug and I can confirm it. When watching a page, Xwiki send out a notification about the change with the following subject and body: Subject: XWiki : Watchlist Updates, 16/04/2009 05:00 Error number 4001 in 4: Error while parsing velocity page XWiki.WatchListMessage Wrapped Exception: Failed to evaluate content with id [XWiki.WatchListMessage] Error number 4001 in 4: Error while parsing velocity page XWiki.WatchListMessage Wrapped Exception: Failed to evaluate content with id [XWiki.WatchListMessage] com.xpn.xwiki.XWikiException: Error number 4001 in 4: Error while parsing velocity page XWiki.WatchListMessage Wrapped Exception: Failed to evaluate content with id [XWiki.WatchListMessage] at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:114) at com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.sendMailFromTemplate(MailSenderPlugin.java:663) at com.xpn.xwiki.plugin.watchlist.WatchListJob.sendNotificationMessage(WatchListJob.java:430) at com.xpn.xwiki.plugin.watchlist.WatchListJob.execute(WatchListJob.java:181) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529) Wrapped Exception: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getExternalURL' in class com.xpn.xwiki.api.Document threw exception java.lang.NullPointerException @ XWiki.WatchListMessage[33,138] at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:286) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203) at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74) at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:448) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:170) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318) at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178) at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143) at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:108) at com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.sendMailFromTemplate(MailSenderPlugin.java:663) at com.xpn.xwiki.plugin.watchlist.WatchListJob.sendNotificationMessage(WatchListJob.java:430) at com.xpn.xwiki.plugin.watchlist.WatchListJob.execute(WatchListJob.java:181) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529) Caused by: java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4368) at com.xpn.xwiki.web.XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java:208) at com.xpn.xwiki.web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178) at com.xpn.xwiki.web.XWikiServletURLFactory.createExternalURL(XWikiServletURLFactory.java:273) at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java:992) at com.xpn.xwiki.api.Document.getExternalURL(Document.java:591) 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:597) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:295) at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245) ... 14 more

    XWiki.org JIRA | 8 years ago | Dave Mangot
    org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getExternalURL' in class com.xpn.xwiki.api.Document threw exception java.lang.NullPointerException @ XWiki.WatchListMessage[33,138]
  2. 0

    I run an instance of XWiki 1.8 in virtual mode behind an Apache server with virtual hosting and reverse proxy. The WatchListMessage job fails and sends the following in the email: {noformat} Error number 4001 in 4: Error while parsing velocity page XWiki.WatchListMessage Wrapped Exception: Failed to evaluate content with id [XWiki.WatchListMessage] Error number 4001 in 4: Error while parsing velocity page XWiki.WatchListMessage Wrapped Exception: Failed to evaluate content with id [XWiki.WatchListMessage] com.xpn.xwiki.XWikiException: Error number 4001 in 4: Error while parsing velocity page XWiki.WatchListMessage Wrapped Exception: Failed to evaluate content with id [XWiki.WatchListMessage] at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:114) at com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.sendMailFromTemplate(MailSenderPlugin.java:662) at com.xpn.xwiki.plugin.watchlist.WatchListJob.sendNotificationMessage(WatchListJob.java:430) at com.xpn.xwiki.plugin.watchlist.WatchListJob.execute(WatchListJob.java:181) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529) Wrapped Exception: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getExternalURL' in class com.xpn.xwiki.api.Document threw exception java.lang.NullPointerException @ XWiki.WatchListMessage[33,138] at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:286) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203) at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74) at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:448) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:170) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318) at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178) at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143) at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:108) at com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.sendMailFromTemplate(MailSenderPlugin.java:662) at com.xpn.xwiki.plugin.watchlist.WatchListJob.sendNotificationMessage(WatchListJob.java:430) at com.xpn.xwiki.plugin.watchlist.WatchListJob.execute(WatchListJob.java:181) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529) Caused by: java.lang.NullPointerException at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java:957) at com.xpn.xwiki.api.Document.getExternalURL(Document.java:591) 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:585) at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:295) at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245) ... 14 more {noformat} Adding some debugging statements to the code, this is actually caused by the following snippet in XWikiServletURLFactory: {code} if (context.getRequest() != null) { // necessary to the tests final String host = context.getRequest().getHeader("x-forwarded-host"); // apache // modproxy host if (host != null) { int comaind = host.indexOf(','); final String host1 = comaind > 0 ? host.substring(0, comaind) : host; if (!host1.equals("")) { serverURL = new URL(context.getRequest().getScheme() + "://" + host1); } } } {code} The URL constructor fails with: {noformat} java.net.MalformedURLException: unknown protocol: null {noformat} This fails because the Request in the context during job execution is an instance of {{XWikiServletRequest}} wrapping a {{com.xpn.xwiki.plugin.scheduler.XWikiServletRequestStub}}. The implementation of {[XWikiServletRequestStub#getScheme}} always returns {{null}} with the current implementation. When the stub instance in initialized in {{SchedulerPlugin#prepareJobStubContext}}, the {{x-forwarded-host}} header is set as the host in the stub request (and the stub request returns the same value for the header) if present (and it will be as Apache sets this proxying the instance). The attached patch fixes this bug.

    XWiki.org JIRA | 8 years ago | Bindul Bhowmik
    org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getExternalURL' in class com.xpn.xwiki.api.Document threw exception java.lang.NullPointerException @ XWiki.WatchListMessage[33,138]
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at com.xpn.xwiki.XWiki.getServletPath()
    2. com.xpn.xwiki
      Document.getExternalURL
      1. com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4368)
      2. com.xpn.xwiki.web.XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java:208)
      3. com.xpn.xwiki.web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178)
      4. com.xpn.xwiki.web.XWikiServletURLFactory.createExternalURL(XWikiServletURLFactory.java:273)
      5. com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java:992)
      6. com.xpn.xwiki.api.Document.getExternalURL(Document.java:591)
      6 frames
    3. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    4. Apache Velocity
      SimpleNode.render
      1. org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:295)
      2. org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:245)
      3. org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:203)
      4. org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:294)
      5. org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74)
      6. org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:448)
      7. org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:170)
      8. org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:318)
      8 frames
    5. org.xwiki.velocity
      DefaultVelocityEngine.evaluate
      1. org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:178)
      2. org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:143)
      2 frames
    6. com.xpn.xwiki
      WatchListJob.execute
      1. com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:108)
      2. com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.sendMailFromTemplate(MailSenderPlugin.java:663)
      3. com.xpn.xwiki.plugin.watchlist.WatchListJob.sendNotificationMessage(WatchListJob.java:430)
      4. com.xpn.xwiki.plugin.watchlist.WatchListJob.execute(WatchListJob.java:181)
      4 frames
    7. quartz
      SimpleThreadPool$WorkerThread.run
      1. org.quartz.core.JobRunShell.run(JobRunShell.java:202)
      2. org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
      2 frames