java.lang.NullPointerException

Atlassian JIRA | Tuomas Jormola | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Hello, I'm trying to export spaces to HTML in a Quartz job. However, this fails when the exporter is gathering resources (images etc.) for the export. This is because resources are being retrieved using an instance of ServletContext but this is not available since the code is not run under a servlet. Here's the stack trace: 2006-10-09 14:54:01,523 ERROR [elma.confluence.export.ExportAllSpacesJob] doExecute Exception while exporting: java.lang.NullPointerException java.lang.NullPointerException at com.atlassian.confluence.util.ServletContextThreadLocal.getContext(ServletContextThreadLocal.java:19) at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.copyExportedResource(AbstractRendererExporterImpl.java:212) at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.copyResources(AbstractRendererExporterImpl.java:184) at com.atlassian.confluence.importexport.impl.HtmlExporter.copyResources(HtmlExporter.java:222) at com.atlassian.confluence.importexport.impl.HtmlExporter.doExportEntity(HtmlExporter.java:211) at com.atlassian.confluence.importexport.impl.HtmlExporter.exportPage(HtmlExporter.java:101) at com.atlassian.confluence.importexport.impl.HtmlExporter.exportSpace(HtmlExporter.java:114) at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.doExport(AbstractRendererExporterImpl.java:102) at com.atlassian.confluence.importexport.impl.HtmlExporter.doExport(HtmlExporter.java:40) at com.atlassian.confluence.importexport.DefaultImportExportManager.exportAs(DefaultImportExportManager.java:113) 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.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152) at $Proxy35.exportAs(Unknown Source) at net.elma.confluence.export.ExportAllSpacesJob.doExecute(ExportAllSpacesJob.java:47) at bucket.event.jobs.AbstractJob.executeInternal(AbstractJob.java:91) at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:66) at org.quartz.core.JobRunShell.run(JobRunShell.java:191) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516) Maybe there should be another way to access the resources which doesn't involve ServletContext? Locally I solved the problem using a crude hack (attached as a patch against Confluence 2.2.9): I created a servlet which is loaded on startup. It saves its context to BootstrapManager as a property. This saved servlet context is then used if one is not available otherwise.

    Atlassian JIRA | 1 decade ago | Tuomas Jormola
    java.lang.NullPointerException
  2. 0

    Hello, I'm trying to export spaces to HTML in a Quartz job. However, this fails when the exporter is gathering resources (images etc.) for the export. This is because resources are being retrieved using an instance of ServletContext but this is not available since the code is not run under a servlet. Here's the stack trace: 2006-10-09 14:54:01,523 ERROR [elma.confluence.export.ExportAllSpacesJob] doExecute Exception while exporting: java.lang.NullPointerException java.lang.NullPointerException at com.atlassian.confluence.util.ServletContextThreadLocal.getContext(ServletContextThreadLocal.java:19) at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.copyExportedResource(AbstractRendererExporterImpl.java:212) at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.copyResources(AbstractRendererExporterImpl.java:184) at com.atlassian.confluence.importexport.impl.HtmlExporter.copyResources(HtmlExporter.java:222) at com.atlassian.confluence.importexport.impl.HtmlExporter.doExportEntity(HtmlExporter.java:211) at com.atlassian.confluence.importexport.impl.HtmlExporter.exportPage(HtmlExporter.java:101) at com.atlassian.confluence.importexport.impl.HtmlExporter.exportSpace(HtmlExporter.java:114) at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.doExport(AbstractRendererExporterImpl.java:102) at com.atlassian.confluence.importexport.impl.HtmlExporter.doExport(HtmlExporter.java:40) at com.atlassian.confluence.importexport.DefaultImportExportManager.exportAs(DefaultImportExportManager.java:113) 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.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152) at $Proxy35.exportAs(Unknown Source) at net.elma.confluence.export.ExportAllSpacesJob.doExecute(ExportAllSpacesJob.java:47) at bucket.event.jobs.AbstractJob.executeInternal(AbstractJob.java:91) at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:66) at org.quartz.core.JobRunShell.run(JobRunShell.java:191) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516) Maybe there should be another way to access the resources which doesn't involve ServletContext? Locally I solved the problem using a crude hack (attached as a patch against Confluence 2.2.9): I created a servlet which is loaded on startup. It saves its context to BootstrapManager as a property. This saved servlet context is then used if one is not available otherwise.

    Atlassian JIRA | 1 decade ago | Tuomas Jormola
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at com.atlassian.confluence.util.ServletContextThreadLocal.getContext()
    2. com.atlassian.confluence
      DefaultImportExportManager.exportAs
      1. com.atlassian.confluence.util.ServletContextThreadLocal.getContext(ServletContextThreadLocal.java:19)
      2. com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.copyExportedResource(AbstractRendererExporterImpl.java:212)
      3. com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.copyResources(AbstractRendererExporterImpl.java:184)
      4. com.atlassian.confluence.importexport.impl.HtmlExporter.copyResources(HtmlExporter.java:222)
      5. com.atlassian.confluence.importexport.impl.HtmlExporter.doExportEntity(HtmlExporter.java:211)
      6. com.atlassian.confluence.importexport.impl.HtmlExporter.exportPage(HtmlExporter.java:101)
      7. com.atlassian.confluence.importexport.impl.HtmlExporter.exportSpace(HtmlExporter.java:114)
      8. com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.doExport(AbstractRendererExporterImpl.java:102)
      9. com.atlassian.confluence.importexport.impl.HtmlExporter.doExport(HtmlExporter.java:40)
      10. com.atlassian.confluence.importexport.DefaultImportExportManager.exportAs(DefaultImportExportManager.java:113)
      10 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:585)
      4 frames
    4. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61)
      2. org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
      3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116)
      3 frames
    5. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56)
      1 frame
    6. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
      2 frames
    7. Unknown
      $Proxy35.exportAs
      1. $Proxy35.exportAs(Unknown Source)
      1 frame
    8. net.elma.confluence
      ExportAllSpacesJob.doExecute
      1. net.elma.confluence.export.ExportAllSpacesJob.doExecute(ExportAllSpacesJob.java:47)
      1 frame
    9. bucket.event.jobs
      AbstractJob.executeInternal
      1. bucket.event.jobs.AbstractJob.executeInternal(AbstractJob.java:91)
      1 frame
    10. Spring Context Support
      QuartzJobBean.execute
      1. org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:66)
      1 frame
    11. quartz
      SimpleThreadPool$WorkerThread.run
      1. org.quartz.core.JobRunShell.run(JobRunShell.java:191)
      2. org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)
      2 frames