java.lang.NullPointerException

Spring JIRA | Craig Walls | 9 years ago
  1. 0

    I'm not sure if this is a Spring-DM issue or a Spring MVC issue, but since it was Spring-DM that exposed it, I'll post it here. If I load my Spring context through DispatcherServlet, everything works fine. But if I use ContextLoaderListener, I get the following stack trace: [Timer-1] ERROR org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext - Refresh error java.lang.NullPointerException at org.springframework.osgi.util.internal.MapBasedDictionary.put(MapBasedDictionary.java:142) at org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext.customizeApplicationContextServiceProperties(OsgiBundleXmlWebApplicationContext.java:176) at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.publishContextAsOsgiServiceIfNecessary(AbstractOsgiBundleApplicationContext.java:283) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.finishRefresh(AbstractDelegatedExecutionApplicationContext.java:307) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:384) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.normalRefresh(AbstractDelegatedExecutionApplicationContext.java:143) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$NoDependenciesWaitRefreshExecutor.refresh(AbstractDelegatedExecutionApplicationContext.java:70) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:131) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer.startCatalinaContext(TomcatWarDeployer.java:144) at org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer.startDeployment(TomcatWarDeployer.java:133) at org.springframework.osgi.web.deployer.support.AbstractWarDeployer.deploy(AbstractWarDeployer.java:93) at org.springframework.osgi.web.extender.internal.activator.WarLoaderListener$DeploymentManager$DeployTask.run(WarLoaderListener.java:141) at org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:66) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) It seems that MapBasedDictionary throws a NullPointerException (at line 142) if either the key or value is null. When OsgiBundleXmlWebApplicationContext tries to add the context's namespace to MapBasedDictionary (line 176), it will fail if the namespace is null. The problem is that the only three places where setNamespace() are called on a web application context are: - FrameworkServlet (and thus DispatcherServlet) - FrameworkPortlet - ContextLoaderPlugin (for Struts apps) In my app, I don't need DispatcherServlet because the front-end is Wicket. But I still need ContextLoaderListener to load the context. Even if I add DispatcherServlet to web.xml, I still get the error. The only way I can get rid of the error is to remove ContextLoaderListener from my web.xml file altogether. So, either (1) ContextLoaderListener needs to be changed to call setNamespace() on the web application context or (2) OsgiBundleXmlWebApplicationContext/MapBasedDictionary needs to be changed to be more forgiving of a null namespace.

    Spring JIRA | 9 years ago | Craig Walls
    java.lang.NullPointerException
  2. 0

    I'm not sure if this is a Spring-DM issue or a Spring MVC issue, but since it was Spring-DM that exposed it, I'll post it here. If I load my Spring context through DispatcherServlet, everything works fine. But if I use ContextLoaderListener, I get the following stack trace: [Timer-1] ERROR org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext - Refresh error java.lang.NullPointerException at org.springframework.osgi.util.internal.MapBasedDictionary.put(MapBasedDictionary.java:142) at org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext.customizeApplicationContextServiceProperties(OsgiBundleXmlWebApplicationContext.java:176) at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.publishContextAsOsgiServiceIfNecessary(AbstractOsgiBundleApplicationContext.java:283) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.finishRefresh(AbstractDelegatedExecutionApplicationContext.java:307) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:384) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.normalRefresh(AbstractDelegatedExecutionApplicationContext.java:143) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$NoDependenciesWaitRefreshExecutor.refresh(AbstractDelegatedExecutionApplicationContext.java:70) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:131) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer.startCatalinaContext(TomcatWarDeployer.java:144) at org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer.startDeployment(TomcatWarDeployer.java:133) at org.springframework.osgi.web.deployer.support.AbstractWarDeployer.deploy(AbstractWarDeployer.java:93) at org.springframework.osgi.web.extender.internal.activator.WarLoaderListener$DeploymentManager$DeployTask.run(WarLoaderListener.java:141) at org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:66) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462) It seems that MapBasedDictionary throws a NullPointerException (at line 142) if either the key or value is null. When OsgiBundleXmlWebApplicationContext tries to add the context's namespace to MapBasedDictionary (line 176), it will fail if the namespace is null. The problem is that the only three places where setNamespace() are called on a web application context are: - FrameworkServlet (and thus DispatcherServlet) - FrameworkPortlet - ContextLoaderPlugin (for Struts apps) In my app, I don't need DispatcherServlet because the front-end is Wicket. But I still need ContextLoaderListener to load the context. Even if I add DispatcherServlet to web.xml, I still get the error. The only way I can get rid of the error is to remove ContextLoaderListener from my web.xml file altogether. So, either (1) ContextLoaderListener needs to be changed to call setNamespace() on the web application context or (2) OsgiBundleXmlWebApplicationContext/MapBasedDictionary needs to be changed to be more forgiving of a null namespace.

    Spring JIRA | 9 years ago | Craig Walls
    java.lang.NullPointerException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 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

    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 org.springframework.osgi.util.internal.MapBasedDictionary.put()
    2. Spring OSGi Core
      MapBasedDictionary.put
      1. org.springframework.osgi.util.internal.MapBasedDictionary.put(MapBasedDictionary.java:142)
      1 frame
    3. org.springframework.osgi
      OsgiBundleXmlWebApplicationContext.customizeApplicationContextServiceProperties
      1. org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext.customizeApplicationContextServiceProperties(OsgiBundleXmlWebApplicationContext.java:176)
      1 frame
    4. Spring OSGi Core
      AbstractDelegatedExecutionApplicationContext.finishRefresh
      1. org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.publishContextAsOsgiServiceIfNecessary(AbstractOsgiBundleApplicationContext.java:283)
      2. org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.finishRefresh(AbstractDelegatedExecutionApplicationContext.java:307)
      2 frames
    5. Spring Context
      AbstractApplicationContext.refresh
      1. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:384)
      1 frame
    6. Spring OSGi Core
      AbstractDelegatedExecutionApplicationContext.refresh
      1. org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.normalRefresh(AbstractDelegatedExecutionApplicationContext.java:143)
      2. org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$NoDependenciesWaitRefreshExecutor.refresh(AbstractDelegatedExecutionApplicationContext.java:70)
      3. org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:131)
      3 frames
    7. Spring
      ContextLoaderListener.contextInitialized
      1. org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
      2. org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
      3. org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
      3 frames
    8. Glassfish Core
      StandardHost.addChild
      1. org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
      2. org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
      3. org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
      4. org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
      5. org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
      5 frames
    9. org.springframework.osgi
      WarLoaderListener$DeploymentManager$DeployTask.run
      1. org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer.startCatalinaContext(TomcatWarDeployer.java:144)
      2. org.springframework.osgi.web.deployer.tomcat.TomcatWarDeployer.startDeployment(TomcatWarDeployer.java:133)
      3. org.springframework.osgi.web.deployer.support.AbstractWarDeployer.deploy(AbstractWarDeployer.java:93)
      4. org.springframework.osgi.web.extender.internal.activator.WarLoaderListener$DeploymentManager$DeployTask.run(WarLoaderListener.java:141)
      4 frames
    10. Spring Context
      DelegatingTimerTask.run
      1. org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:66)
      1 frame
    11. Java RT
      TimerThread.run
      1. java.util.TimerThread.mainLoop(Timer.java:512)
      2. java.util.TimerThread.run(Timer.java:462)
      2 frames