Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-5247

Broken Link in Tomcat because of Page Mount

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 6.8.0
    • Fix Version/s: 6.9.0, 1.5.11, 7.0.0-M1
    • Component/s: wicket-quickstart
    • Labels:
      None
    • Environment:
      Tomcat 7.0.41

      Description

      I post this message on the user mailing List (http://apache-wicket.1842946.n4.nabble.com/Broken-Link-in-Tomcat-because-of-Page-Mount-tt4659663.html) and Martin Grigorov asked me, to create a ticket on Jira.

      Broken Link in Tomcat because of Page Mount

      Following situation:
      -I have a Wicket Application(6.8.0) which runs under the context "webapp" on a Tomcat 7.0.41
      -I mount a Page with two parameters (this is important) in the WicketApplication.
      mountPage("/mount/$

      {parameter1}

      /$

      {parameter2}

      ", MountedPage.class);
      -The mounted Page(MountedPage.class) has only a simple Link
      -There are two links on the HomePage to the mounted Page.
      They are declared as follows:

      add(new Link<Void>("link") {
      @Override
      public void onClick()

      { setResponsePage(MountedPage.class, linkParameters); }

      });

      add(new Link<Void>("brokenLink") {
      @Override
      public void onClick()

      { setResponsePage(new MountedPage(linkParameters)); }

      });

      I deploy this Application as a war file on a Tomcat under the context "webapp".
      When I call the first Link on the HomePage and then the Link on the mounted Page, everything works fine.

      But if I call the second Link and then the Link on the mounted Page, the link is broken.
      The context is missing in the generated link
      http://localhost:8080/wicket/bookmarkable/com.mycompany.LinkedPage

      Does anyone have an idea, why the second link does not work on Tomcat?

      I add a Quickstart and the war file as attachment.

      Ps: Both links works fine in Jetty.
      Pss:If I remove the mount command, both links will work in Tomcat too.

      1. quickstart.zip
        26 kB
        Martin Wischnewski
      2. webapp.war
        2.53 MB
        Martin Wischnewski

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user martin-g commented on a diff in the pull request:

          https://github.com/apache/wicket/pull/210#discussion_r99945970

          — Diff: wicket-core/src/test/java/org/apache/wicket/core/request/mapper/MountedMapperTest.java —
          @@ -714,7 +714,7 @@ public boolean isNewPageInstance()
          @Test
          public void placeholderEncode4()
          {

          • PageProvider provider = new PageProvider(new MockPage())
            + PageProvider provider = new PageProvider(MockPage.class)
              • End diff –

          I didn't understand you.
          ```java
          /**

          • WICKET-5247 page instantiated without required parameters won't be mapped
            */
            @Test
            public void placeholderEncode4()
            {
            PageProvider provider = new PageProvider(new MockPage())
            Unknown macro: { @Override public boolean isNewPageInstance() { return false; } }

            ;
            provider.setPageSource(context);
            IRequestHandler handler = new RenderPageRequestHandler(provider);
            Url url = placeholderEncoder.mapHandler(handler);
            assertNull(url);
            }
            ```
            The test setups a PageProvider and uses it. There is no replacement after.
            By making this change I think we don't test the same as what broke in WICKET-5247.

          Show
          githubbot ASF GitHub Bot added a comment - Github user martin-g commented on a diff in the pull request: https://github.com/apache/wicket/pull/210#discussion_r99945970 — Diff: wicket-core/src/test/java/org/apache/wicket/core/request/mapper/MountedMapperTest.java — @@ -714,7 +714,7 @@ public boolean isNewPageInstance() @Test public void placeholderEncode4() { PageProvider provider = new PageProvider(new MockPage()) + PageProvider provider = new PageProvider(MockPage.class) End diff – I didn't understand you. ```java /** WICKET-5247 page instantiated without required parameters won't be mapped */ @Test public void placeholderEncode4() { PageProvider provider = new PageProvider(new MockPage()) Unknown macro: { @Override public boolean isNewPageInstance() { return false; } } ; provider.setPageSource(context); IRequestHandler handler = new RenderPageRequestHandler(provider); Url url = placeholderEncoder.mapHandler(handler); assertNull(url); } ``` The test setups a PageProvider and uses it. There is no replacement after. By making this change I think we don't test the same as what broke in WICKET-5247 .
          Hide
          martin wischnewski Martin Wischnewski added a comment -

          Thanks for the quick fix!

          Show
          martin wischnewski Martin Wischnewski added a comment - Thanks for the quick fix!
          Hide
          svenmeier Sven Meier added a comment -

          Should have checked the console output - fatal: Authentication failed

          Show
          svenmeier Sven Meier added a comment - Should have checked the console output - fatal: Authentication failed
          Hide
          mgrigorov Martin Grigorov added a comment -

          Sven,

          I see commits only in 6.x and master.
          Did you forget to push to 1.5.x ? 1.5.11 is in "Fix Version"

          Show
          mgrigorov Martin Grigorov added a comment - Sven, I see commits only in 6.x and master. Did you forget to push to 1.5.x ? 1.5.11 is in "Fix Version"
          Hide
          svenmeier Sven Meier added a comment -

          the handler is no longer mapped by MountedMapper when the value for a required placeholder is
          missing

          Show
          svenmeier Sven Meier added a comment - the handler is no longer mapped by MountedMapper when the value for a required placeholder is missing
          Hide
          svenmeier Sven Meier added a comment -

          As a quick fix you can pass the PageParameters to the super constructor:

          public MountedPage(PageParameters parameters)

          { super(parameters); ... }

          Otherwise there is no way for Wicket to know and use them in the generation of the mounted url.

          I will commit a fix that improves handling of this coding error.

          Show
          svenmeier Sven Meier added a comment - As a quick fix you can pass the PageParameters to the super constructor: public MountedPage(PageParameters parameters) { super(parameters); ... } Otherwise there is no way for Wicket to know and use them in the generation of the mounted url. I will commit a fix that improves handling of this coding error.

            People

            • Assignee:
              svenmeier Sven Meier
              Reporter:
              martin wischnewski Martin Wischnewski
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development