Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4244

ShowConfigAction.execute() throws InstantiationException when the Action has NO nullary constructor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.15.3
    • 2.3.20
    • None

    Description

      In my case, I use Guice for DI and constructor injection is used in many Actions.
      When I enable the Config Browser feature and click the Action in the Action information page, it shows the error message

      Unable to execute org.apache.struts2.config_browser.ShowConfigAction

      After a brief code tracing, I found that in the ShowConfigAction.execute(), it uses clazz.newInstance() for creating the action instance. And the java-doc of the newInstance() claims that it would throw the InstantiationException if the class has no nullary constructor.

      I think one of the quick fix would be added default-constructor into those Actions(I have tested it and it works). However, I think it would not be a good solution as the extra constructor is a redundancy to me and would increase the maintenance cost.

      I am wondering if the ShowConfigAction could use ObjectFactory.buildBean() for creating the action instance.

      P.S: Please correct me if I use the Config Browser Plugin in the wrong way.

      Attachments

        1. WW4244.patch
          1 kB
          Harry Chan

        Activity

          People

            lukaszlenart Lukasz Lenart
            harry.chan Harry Chan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: