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

ControllerClasspathPackageProvider causes duplicate package error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.0
    • 2.1.2
    • Plugin - REST
    • None

    Description

      If a REST Controller (aka action) implements Action or is annotated with @Action, the CodeBehind PackageProvider and the REST PackageProvider both attempt to create the parent package. This results in a duplicate package error while building the configuration:
      ...
      Caused by: The package name 'mypackage.actions.parent' at location null is already been used by another package at location null

      The reason is that CodeBehind's ClasspathPackageProvider detects the action and configures the parent package, and the ControllerClasspathPackageProvider (re)detects the Controller and configures the parent package.

      As it exists, this will be a common error as uses may tend to extend ActionSupport to access ValidationAwareSupport and TextProviderSupport within a Controller.

      Possible resolutions:

      • REST plugin does not configure Controllers that are also Actions; or
      • REST plugin provides unique names for the parent packages it creates (currently it uses the java package name)

      I prefer the latter but aren't sure of the implications. The change would also impact the CodeBehind.

      I believe this only affects 2.1.1+ due to the strict configuration. It can be replicated by changing the rest-showcase Controller to extend ActionSupport rather than ValidationAwareSupport.

      Attachments

        Activity

          People

            mrdon Donald J. Brown
            jeromy Jeromy Evans
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: