1. Cocoon
  2. COCOON-2319

Bad Environment context when redirecting to cocoon:// with a sitemap not located in the webapp context


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.11
    • Fix Version/s: 2.1.12
    • Component/s: * Cocoon Core
    • Labels:
    • Other Info:
      Patch available


      Let say I have a root sitemap not located in the webapp context, with a simple pipeline like :

      <map:match pattern="foo">
        <map:read src="foo.png"/>

      If I call directly, the URI /foo, I correctly get the image foo.png

      Now, if I have a second sitemap elsewhere, mounted from the first one, with another simple pipeline like :

      <map:match pattern="bar">
        <map:redirect-to uri="cocoon://foo"/>

      If I call /foo/bar, I get a 404 Not Found saying that it looks for foo.png in the webapp context, and not relative to the root sitemap.

      Looking at the code, I discovered that in the first case, in the method TreeProcessor.setupConcreteProcessor(), we have a statement especially for handling the case of sitemap not located in the webapp context :
              if (this.parent == null) {
                  // Ensure root sitemap uses the correct context, even if not located in the webapp context
                  env.changeContext("", this.source.getURI());

      while in the second case, where the ConcreteTreeProcessor is managed in the method ConcreteTreeProcessor.handleCocoonRedirect(), there's no such statement.

      I'll provide a patch for fixing this, but looking deeper at the code, I found that this looked like a hack (even for the existing statement).
      I think it would be better to have the right root context at the creation of the environment, and not to have to change it later when building the ConcreteTreeProcessor.


        Cédric Damioli created issue -
        Cédric Damioli made changes -
        Field Original Value New Value
        Attachment [ 12506986 ]
        Cédric Damioli made changes -
        Other Info Patch available [ 10054 ]
        Cédric Damioli added a comment -
        Committed in revision 1303732
        Cédric Damioli added a comment - Committed in revision 1303732
        Cédric Damioli made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Cédric Damioli [ cedric ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        119d 23h 20m 1 Cédric Damioli 10/Apr/12 09:40


          • Assignee:
            Cédric Damioli
            Cédric Damioli
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: