Struts 2
  1. Struts 2
  2. WW-2956

setting devMode value to "true" causes NullPointerException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.1.6
    • Fix Version/s: 2.1.8
    • Component/s: None
    • Labels:
      None
    • Environment:

      Windows 2003 Server SP2, JRE 1.6.0_07, Tomcat 6.0.18

      Description

      I enabled devMode in struts2-blank-2.1.6 application and it's caused such deployment exception:

      org.apache.catalina.core.StandardContext filterStart
      SEVERE: Exception starting filter struts2
      java.lang.NullPointerException
      at com.opensymphony.xwork2.util.FileManager$FileRevision.needsReloading(FileManager.java:209)
      at com.opensymphony.xwork2.util.FileManager.fileNeedsReloading(FileManager.java:60)
      at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.needsReload(XmlConfigurationProvider.java:325)
      at org.apache.struts2.config.StrutsXmlConfigurationProvider.needsReload(StrutsXmlConfigurationProvider.java:168)
      at com.opensymphony.xwork2.config.ConfigurationManager.conditionalReload(ConfigurationManager.java:220)
      at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:61)
      at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:774)
      at org.apache.struts2.dispatcher.ng.InitOperations.initStaticContentLoader(InitOperations.java:77)
      at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:49)
      at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
      at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
      at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
      at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4363)
      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.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
      at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
      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:117)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(StandardService.java:516)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

      Also struts2-showcase-2.1.6 (where devMode is default) throws same exception:
      org.apache.catalina.core.StandardWrapperValve invoke
      SEVERE: Servlet.service() for servlet jsp threw exception
      java.lang.NullPointerException
      at com.opensymphony.xwork2.util.FileManager$FileRevision.needsReloading(FileManager.java:209)
      at com.opensymphony.xwork2.util.FileManager.fileNeedsReloading(FileManager.java:60)
      at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.needsReload(XmlConfigurationProvider.java:325)
      at org.apache.struts2.config.StrutsXmlConfigurationProvider.needsReload(StrutsXmlConfigurationProvider.java:168)
      at com.opensymphony.xwork2.config.ConfigurationManager.conditionalReload(ConfigurationManager.java:220)
      at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:61)
      at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:774)
      at org.apache.struts2.dispatcher.ng.PrepareOperations.createActionContext(PrepareOperations.java:74)
      at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:59)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
      at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:857)
      at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565)
      at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
      at java.lang.Thread.run(Unknown Source)

      1. WW-2956.patch
        7 kB
        Lukasz Lenart
      2. WW-2956-1.patch
        7 kB
        Lukasz Lenart

        Activity

        Hide
        Andrea Ceccanti added a comment -

        I didn't try the latest builds, I am speaking about 2.1.6. In my setup the error is raised even if there are no spaces in

        • the tomcat installation path : /opt/tomcat/apache-tomcat-5.5.27
        • the webapplication context path: /opt/tomcat/apache-tomcat-5.5.27/webapps/voms#test_vo_mysql

        So it could be that the presence of spaces isn't the only reason behind this bug.

        Show
        Andrea Ceccanti added a comment - I didn't try the latest builds, I am speaking about 2.1.6. In my setup the error is raised even if there are no spaces in the tomcat installation path : /opt/tomcat/apache-tomcat-5.5.27 the webapplication context path: /opt/tomcat/apache-tomcat-5.5.27/webapps/voms#test_vo_mysql So it could be that the presence of spaces isn't the only reason behind this bug.
        Hide
        Dave Newton added a comment -

        I still have to try with the latest--but just to add:

        It's not just the Tomcat install directory--it's the app deploy directory. Under IntelliJ, for example, if I have a run config that creates an exploded app in a directory w/ spaces the error also happens, even though my Tomcat install itself isn't on a path with spaces. Same issue, but can get there in different ways.

        Show
        Dave Newton added a comment - I still have to try with the latest--but just to add: It's not just the Tomcat install directory--it's the app deploy directory. Under IntelliJ, for example, if I have a run config that creates an exploded app in a directory w/ spaces the error also happens, even though my Tomcat install itself isn't on a path with spaces. Same issue, but can get there in different ways.
        Hide
        Lukasz Lenart added a comment -

        Did you try to use latest Struts2 build [1] or Xwork build [2]?

        [1] http://people.apache.org/builds/struts/nightlies/2.x/
        [2] http://www.lenart.org.pl/maven/com/opensymphony/xwork/

        Regards

        Lukasz

        Show
        Lukasz Lenart added a comment - Did you try to use latest Struts2 build [1] or Xwork build [2] ? [1] http://people.apache.org/builds/struts/nightlies/2.x/ [2] http://www.lenart.org.pl/maven/com/opensymphony/xwork/ Regards – Lukasz
        Hide
        Andrea Ceccanti added a comment -

        Setting my webapp to devMode with struts 2.1.6 causes the same error, even if the path leading to my tomcat installation contains no spaces.

        nope:logs andrea$ echo $CATALINA_HOME
        /opt/tomcat/apache-tomcat-5.5.27

        Show
        Andrea Ceccanti added a comment - Setting my webapp to devMode with struts 2.1.6 causes the same error, even if the path leading to my tomcat installation contains no spaces. nope:logs andrea$ echo $CATALINA_HOME /opt/tomcat/apache-tomcat-5.5.27
        Hide
        Lukasz Lenart added a comment -

        Committed to xwork trunk, revision 1911

        Show
        Lukasz Lenart added a comment - Committed to xwork trunk, revision 1911
        Hide
        musachy added a comment -

        Yes, that's better.

        Show
        musachy added a comment - Yes, that's better.
        Hide
        Lukasz Lenart added a comment -

        Instead of using default constructor for FileRevision (which should be removed), just Revision object should be created like in case of Jar file. Then check for null is not needed any more.

        Show
        Lukasz Lenart added a comment - Instead of using default constructor for FileRevision (which should be removed), just Revision object should be created like in case of Jar file. Then check for null is not needed any more.
        Hide
        musachy added a comment -

        The try/catch part is good, but I think the check for null should stay in place, as long as there is a constructor of FileRevision that doesn't take a file parameter. For example, if the file cannot be read, then "file" will be set to null, in that method, and the NPE will be triggered. Trying to think outside the box, why keep track of a "file" that can never be reloaded anyway? If the file cannot be read, or it does not exists, we should not add it to the map at all.

        Show
        musachy added a comment - The try/catch part is good, but I think the check for null should stay in place, as long as there is a constructor of FileRevision that doesn't take a file parameter. For example, if the file cannot be read, then "file" will be set to null, in that method, and the NPE will be triggered. Trying to think outside the box, why keep track of a "file" that can never be reloaded anyway? If the file cannot be read, or it does not exists, we should not add it to the map at all.
        Hide
        Lukasz Lenart added a comment -

        XWork patch

        Show
        Lukasz Lenart added a comment - XWork patch
        Hide
        Lukasz Lenart added a comment -

        I think, I found better solution, please see attached patch

        Show
        Lukasz Lenart added a comment - I think, I found better solution, please see attached patch
        Hide
        musachy added a comment -

        It seems like this happens when tomcat is installed on a directory that has spaces. Fixed on xwork trunk rv 1909

        Show
        musachy added a comment - It seems like this happens when tomcat is installed on a directory that has spaces. Fixed on xwork trunk rv 1909

          People

          • Assignee:
            Unassigned
            Reporter:
            Semion Oshchepkov
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development