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

REST service actions and "normal" actions in the same web application (patch)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.2.1.1
    • 2.2.3
    • Plugin - REST
    • N/A

    • Patch

    Description

      Problem.
      i would like to expand my existing webapp by adding RESTful ws. i do not want to create a separate webapp which would serve solely as web service.
      but as soon as i add REST plugin to th classpath of my struts2 based webapp, all actions (which worked correctly before) stop working and i get errors:
      java.lang.NoSuchMethodException <...> MyActionName.index().

      i thought that it could be solved by reconfiguring "ActionMapper"s. i configured that in this way:
      <constant name="struts.mapper.class"
      value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper"/>
      <constant name="struts.mapper.prefixMapping" value="/ws/rest:rest,:struts"/>

      but this does not solves the problem. "normal" actions throw "Cannot handle CGLIB enhanced proxies with multiple callbacks"..

      Solution.

      i suggest to implement conditional enabling (based on the namespace of the request) of the REST plugin. this can be done by changing RestActionProxyFactory class a little bit. my solution (see the patch) adds a "namespace" property (with setter only). that property has default value or can have injected a config value named "struts.rest.namespace". the default value is "/" which means that after update the functionality of the plugin will remain the same unless one adds a config like:
      <constant name="struts.rest.namespace" value="/rest" />

      Attachments

        1. rest namespace patch.txt
          2 kB
          Raigedas

        Activity

          People

            lukaszlenart Lukasz Lenart
            raigedas Raigedas
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 10m
                10m
                Remaining:
                Remaining Estimate - 10m
                10m
                Logged:
                Time Spent - Not Specified
                Not Specified