Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-4787

404 page not found error even a build is triggered successfully

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: core
    • Labels:
      None
    • Environment:
      Platform: PC, OS: All
    • Similar Issues:

      Description

      When a build is triggered using the following code, an 404 error returns even
      the build it triggered successfully.

      String uri = "Hudson build page/build?token=build_me";
      DocumentBuilder parser =
      DocumentBuilderFactory.newInstance().newDocumentBuilder();
      URLConnection connection = new URL(uri).openConnection();
      connection.connect();
      InputStream is = connection.getInputStream();
      Document document = parser.parse(is);

        Attachments

          Activity

          Hide
          mindless Alan Harder added a comment -

          davehun, what web container do you use?
          I just tried SJSAS 9_1_02 and I was able to see the problem.. looking into why
          the "." gets appended on the redirect URL when running in SJSAS9. It does work
          with wget, as wget appears to trim the trailing "." before following the
          redirect.. but java takes the redirect as given and gets the 404.

          Show
          mindless Alan Harder added a comment - davehun, what web container do you use? I just tried SJSAS 9_1_02 and I was able to see the problem.. looking into why the "." gets appended on the redirect URL when running in SJSAS9. It does work with wget, as wget appears to trim the trailing "." before following the redirect.. but java takes the redirect as given and gets the 404.
          Hide
          mindless Alan Harder added a comment -

          https://stapler.dev.java.net/source/browse/stapler/trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java?annotate=998

          Looks like the problem is line 96 here.. the lines above it calculate "base" but
          in the end it just passes "url" to super.sendRedirect(), and in this case url is
          "." (from forwardToPreviousPage above, at line 76).

          Show
          mindless Alan Harder added a comment - https://stapler.dev.java.net/source/browse/stapler/trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java?annotate=998 Looks like the problem is line 96 here.. the lines above it calculate "base" but in the end it just passes "url" to super.sendRedirect(), and in this case url is "." (from forwardToPreviousPage above, at line 76).
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in stapler
          User: : mindless
          Path:
          trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java
          https://stapler.dev.java.net/source/browse/stapler/trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java?view=diff&rev=1241&p1=trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java&p2=trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java&r1=1240&r2=1241

          Log:
          JENKINS-4787 r754 added some code to generate an absolute path for a redirect,
          but in the end it does super.sendRedirect(url) with the original given relative path
          instead of the absolute path it built.. in particular, if the relative path was "."
          this actually gets sent to super.sendRedirect(). SJSAS9 container actually includes
          this "." in the redirect URL. Changed to super.sendRedirect(base) so redirect won't
          include trailing "."

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in stapler User: : mindless Path: trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java https://stapler.dev.java.net/source/browse/stapler/trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java?view=diff&rev=1241&p1=trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java&p2=trunk/stapler/core/src/main/java/org/kohsuke/stapler/ResponseImpl.java&r1=1240&r2=1241 Log: JENKINS-4787 r754 added some code to generate an absolute path for a redirect, but in the end it does super.sendRedirect(url) with the original given relative path instead of the absolute path it built.. in particular, if the relative path was "." this actually gets sent to super.sendRedirect(). SJSAS9 container actually includes this "." in the redirect URL. Changed to super.sendRedirect(base) so redirect won't include trailing "."
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in hudson
          User: : mindless
          Path:
          trunk/hudson/main/core/pom.xml
          trunk/www/changelog.html
          http://fisheye4.cenqua.com/changelog/hudson/?cs=23658
          Log:
          [FIXED JENKINS-4787] use latest stapler with fix so we don't redirect to "." (stapler r1241)

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in hudson User: : mindless Path: trunk/hudson/main/core/pom.xml trunk/www/changelog.html http://fisheye4.cenqua.com/changelog/hudson/?cs=23658 Log: [FIXED JENKINS-4787] use latest stapler with fix so we don't redirect to "." (stapler r1241)
          Hide
          zhipeng zhipeng added a comment -

          Verified.

          Show
          zhipeng zhipeng added a comment - Verified.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            zhipeng zhipeng
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: