-
Bug
-
Resolution: Fixed
-
Major
-
None
-
Platform: PC, OS: All
-
Powered by SuggestiMate
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);
[JENKINS-4787] 404 page not found error even a build is triggered successfully
No 404 errwas produced in version 1.308.
It seems that the issue is not caused by DocumentBuilder becaise it can still be
produced using these code:
URLConnection connection = new URL(uri).openConnection();
connection.connect();
InputStream is = connection.getInputStream();
The exception thrown is java.io.FileNotFoundException not a
ParserConfigurationException or SAXException.
Here is the stack trace:
Exception in thread "main" java.io.FileNotFoundException
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1288)
at org.kun.javaexamples.web.HttpGetter.main(HttpGetter.java:22)
These are the network information caught by Wireshark:
......
Accept: text/html, image/gif, image/jpeg, ; q=.2, */; q=.2
Connection: keep-alive
HTTP/1.1 404 Not Found
X-Powered-By: Servlet/2.5
Server: Sun Java System Application Server 9.1_02
Set-Cookie: JSESSIONID=8c22f27610cf10389d7fd48b4474; Path=/hudson
Content-Type: text/html
Content-Language:
Content-Length: 1028
Date: Thu, 15 Oct 2009 15:12:51 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>Sun Java
System Application Server 9.1_02 - Error report</title><style
type="text/css"><!--H1 ...........
can you include more of the network capture? What was the HTTP response code
and Location header from the original request? ie, what URL is giving the 404
response and FileNotFoundException?
I wasn't able to reproduce this problem using wget or a java program.. both
redirected and read the project page OK. I also tried with a space in the
project name (using %20 in the URL) and that worked fine.. any other special
characters in your URL that may trigger this?
Hi mindless,
If I use this code:
public static void main(String[] args) throws ParserConfigurationException,
SAXException, IOException
to trigger the page.
I will get this exception:
Exception in thread "main" java.io.FileNotFoundException:
http://crafnanta:8081/hudson/view/Buttermere-Dev/job/MSXI%20Dev%20-%20Webstart%20Upload%20Scanner/.
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1288)
at HttpTrigger.main(HttpTrigger.java:20)
And in Wireshark I can capture this:
GET
/hudson/view/Buttermere-Dev/job/MSXI%20Dev%20-%20Webstart%20Upload%20Scanner/.
HTTP/1.1
User-Agent: Java/1.6.0_10
Host: crafnanta:8081
Accept: text/html, image/gif, image/jpeg, ; q=.2, */; q=.2
Connection: keep-alive
HTTP/1.1 404 Not Found
X-Powered-By: Servlet/2.5
Server: Sun Java System Application Server 9.1_02
Set-Cookie: JSESSIONID=3d5060d18300086ba5f8a9a71fe6; Path=/hudson
Content-Type: text/html
Content-Language:
Content-Length: 1028
Date: Wed, 11 Nov 2009 15:20:38 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>Sun Java
System Application Server 9.1_02 - Error report</title><style
type="text/css"><!--H1
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}HR
{color : #525D76;}--></style> </head><body><h1>HTTP Status
404 - </h1><hr/><p><b>type</b> Status
report</p><p><b>message</b></p><p><b>description</b>The requested resource () is
not available.</p><hr/><h3>Sun Java System Application Server
9.1_02</h3></body></html>
Hope this helps.
Thanks
Can you post the whole set of requests instead of just the last one? Is that
"." really on the end of the redirect URL?
Also, you mentioned 1.308 worked ok, what Hudson version are you using now?
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.
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).
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 "."
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)
After the build is triggered it sends a redirect back to the build page, so the
404 must be in following the redirect since you do see the build start. The
build page is html, not xml, so not sure a DocumentBuilder can parse it.