Struts 2
  1. Struts 2
  2. WW-3486

NullPointerException on struts initialization

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Not a Problem
    • Affects Version/s: 2.1.8.1, 2.2.1
    • Fix Version/s: None
    • Component/s: Plugin - Convention
    • Labels:
      None
    • Environment:

      Tomcat 5.5.26 jdk 1.6.0_01-b06 struts 2.2.1

    • Flags:
      Patch, Important

      Description

      When migrate from 2.1.8.1 to 2.2.1 the same project fails in initialization, in the convention plugin PackageBasedconfigBuilder method buildconfiguration line 592 it seems the method getPackge() return null. I solve the problem replace convention-plugin 2.2.1 for 2.1.8.1.

      I dont make extensive test but works fine replacing the library.

      1. WW-3486.patch
        1 kB
        Maurizio Cucchiara
      2. struts.xml
        0.7 kB
        David Altenhof

        Activity

        Hide
        David Altenhof added a comment - - edited

        I'm also getting this. Partial stack trace:

        ERROR org.apache.struts2.dispatcher.Dispatcher.error:38 - Dispatcher initialization failed
        java.lang.NullPointerException
        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:592)
        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:336)
        at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)

        [snip]

        Show
        David Altenhof added a comment - - edited I'm also getting this. Partial stack trace: ERROR org.apache.struts2.dispatcher.Dispatcher.error:38 - Dispatcher initialization failed java.lang.NullPointerException at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:592) at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:336) at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55) [snip]
        Hide
        Lukasz Lenart added a comment -

        Could you both post the whole stack traces?

        Show
        Lukasz Lenart added a comment - Could you both post the whole stack traces?
        Hide
        Hugo Robayo added a comment -

        This is the stack trace

        [ERROR] Dispatcher initialization failed
        java.lang.NullPointerException
        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:592)
        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:336)
        at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:448)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
        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.catalina.startup.Bootstrap.start(Bootstrap.java:295)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
        [ERROR] Excepción arrancando filtro struts2
        Class: org.apache.struts2.convention.PackageBasedActionConfigBuilder
        File: PackageBasedActionConfigBuilder.java
        Method: buildConfiguration
        Line: 592 - org/apache/struts2/convention/PackageBasedActionConfigBuilder.java:592:-1
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
        at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:448)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
        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.catalina.startup.Bootstrap.start(Bootstrap.java:295)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
        Caused by: java.lang.NullPointerException
        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:592)
        at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:336)
        at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
        ... 29 more

        Show
        Hugo Robayo added a comment - This is the stack trace [ERROR] Dispatcher initialization failed java.lang.NullPointerException at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:592) at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:336) at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022) at org.apache.catalina.core.StandardHost.start(StandardHost.java:736) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:448) at org.apache.catalina.core.StandardServer.start(StandardServer.java:700) at org.apache.catalina.startup.Catalina.start(Catalina.java:552) 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.catalina.startup.Bootstrap.start(Bootstrap.java:295) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433) [ERROR] Excepción arrancando filtro struts2 Class: org.apache.struts2.convention.PackageBasedActionConfigBuilder File: PackageBasedActionConfigBuilder.java Method: buildConfiguration Line: 592 - org/apache/struts2/convention/PackageBasedActionConfigBuilder.java:592:-1 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022) at org.apache.catalina.core.StandardHost.start(StandardHost.java:736) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:448) at org.apache.catalina.core.StandardServer.start(StandardServer.java:700) at org.apache.catalina.startup.Catalina.start(Catalina.java:552) 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.catalina.startup.Bootstrap.start(Bootstrap.java:295) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433) Caused by: java.lang.NullPointerException at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.java:592) at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:336) at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:53) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415) ... 29 more
        Hide
        Maurizio Cucchiara added a comment -

        I'm pretty sure it is caused by the configuration.
        Could you post your struts. xml file?

        Show
        Maurizio Cucchiara added a comment - I'm pretty sure it is caused by the configuration. Could you post your struts. xml file?
        Hide
        Hugo Robayo added a comment -

        I modify struts.convention.exclude.packages constant name trying to fix this issue without successful result.

        <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
        <struts>

        <!-- Include webwork default (from the Struts JAR). -->
        <include file="struts-default.xml"/>

        <constant name="struts.objectFactory.spring.autoWire" value="auto" />

        <!-- SOLO PARA DESARROLLO -->
        <constant name="struts.devMode" value="true" />
        <constant name="struts.convention.classes.reload" value="true" />

        <!-- Convention configuration -->
        <constant name="struts.convention.result.path" value="/WEB-INF/jsp" />
        <constant name="struts.convention.exclude.packages" value="org.apache.struts.,org.apache.struts2.,org.springframework.web.struts.,org.springframework.web.struts2.,org.hibernate.,ec.gov.dirnea.common." />

        </struts>

        Show
        Hugo Robayo added a comment - I modify struts.convention.exclude.packages constant name trying to fix this issue without successful result. <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <!-- Include webwork default (from the Struts JAR). --> <include file="struts-default.xml"/> <constant name="struts.objectFactory.spring.autoWire" value="auto" /> <!-- SOLO PARA DESARROLLO --> <constant name="struts.devMode" value="true" /> <constant name="struts.convention.classes.reload" value="true" /> <!-- Convention configuration --> <constant name="struts.convention.result.path" value="/WEB-INF/jsp" /> <constant name="struts.convention.exclude.packages" value="org.apache.struts. ,org.apache.struts2. ,org.springframework.web.struts. ,org.springframework.web.struts2. ,org.hibernate. ,ec.gov.dirnea.common. " /> </struts>
        Hide
        Maurizio Cucchiara added a comment -

        As I suspected there something that go wrong with struts.convention.classes.reload constant.
        Could you try to set reload to false (while waiting for a patch) and tell me what happen?

        Show
        Maurizio Cucchiara added a comment - As I suspected there something that go wrong with struts.convention.classes.reload constant. Could you try to set reload to false (while waiting for a patch) and tell me what happen?
        Hide
        Maurizio Cucchiara added a comment -

        if you take a look at http://struts.apache.org/2.2.1/docs/convention-plugin.html#ConventionPlugin-Automaticconfigurationreloading, you'll notice how the usage is highly discouraged.

        Show
        Maurizio Cucchiara added a comment - if you take a look at http://struts.apache.org/2.2.1/docs/convention-plugin.html#ConventionPlugin-Automaticconfigurationreloading , you'll notice how the usage is highly discouraged.
        Hide
        Hugo Robayo added a comment -

        You are right, this is the problem, thank you very much.

        Show
        Hugo Robayo added a comment - You are right, this is the problem, thank you very much.
        Hide
        Maurizio Cucchiara added a comment -

        The attached patch fixes the problem.
        There should be no side effects.

        Could you test it?

        Show
        Maurizio Cucchiara added a comment - The attached patch fixes the problem. There should be no side effects. Could you test it?
        Hide
        Lukasz Lenart added a comment -

        Patch committed, please try download files from here
        https://hudson.apache.org/hudson/view/Struts/job/Struts2/

        Show
        Lukasz Lenart added a comment - Patch committed, please try download files from here https://hudson.apache.org/hudson/view/Struts/job/Struts2/

          People

          • Assignee:
            Lukasz Lenart
            Reporter:
            Hugo Robayo
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development