Server returned HTTP response code: 500 for URL [closed]
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this questionjava.io.IOException: Server returned HTTP response code: 500 for URL: http://ww
.huadt.com.cn/zh-cn/i/l/@357671030745308@V500@0000@AUTOLOW@1@11d590f7$GPRMC,065
48.000,A,3959.8587,N,11617.2447,E,0.00,55.32,210311,,,A*56@@
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown S
urce)
at hdt.SendCmdToP.Sendplatform(SendCmdToP.java:67)
at hdt.SendCmdToP.process(SendCmdToP.java:198)
at hdt.SendCmdToP.run(SendCmdToP.java:131)
java.lang.NullPointerException
at hdt.SendCmdToP.Sendplatform(SendCmdToP.java:91)
at hdt.SendCmdToP.process(SendCmdToP.java:198)
at hdt.SendCmdToP.run(SendCmdToP.java:131)
Appeared pointer, and 500 wrong with the closure of the abnormal, a firewall relationship? If not is it code problems? Please help everybody see how to solve the problem. thanks。
A 500 response means that the server has detected an internal error. There could be any number of causes.
The best place to look for information on what caused the error is the server logs. But failing that, there maybe some additional diagnostic information in the URLConnection object's "error" stream. Try opening that and copying its contents to standard output, or a logger.
Or just visit the URL in your web browser or using wget or curl, and look at the error message it shows you.
(You have to be cautious with using other tools, because it is conceivable that the problem is caused by something in the HTTP request headers ... and these are likely to depend on the tool that you use to fetch the URL.)
It's not clear exactly what you're showing in the log - this looks like two separate exceptions to me. Is it possible that you're logging the first exception (which indicates a server error) but ignoring it, and trying to carry on? That could easily lead to a NullPointerException later. If you catch an exception and don't rethrow it (or a different exception), you need to really handle the exception - the rest of the code will need to work appropriately.
I think you need to work on three aspects:
- Check that my understanding of the situation is correct. Understand why you've got two exceptions logged.
- Work out why the web server is failing to return data for that URL. If you own the other server, you should look at its logs. If it's another Java server, chances are that 500 represents an unhandled exception.
- Fix your code so that it handles web server failures better - i.e. so that one error doesn't cause another. Perhaps your code should simply not catch the IOException to start with, but allow it to be propagated up the stack to some top-level handler which will log it and make the overall action fail in an appropriate manner? (This depends on the kind of application you're running, of course.)
First off you need 'www' not 'ww' in your url. Second, when you make a curl request of the corrected url you get an internal error message:
Internal Error
The Web server (running the Web Site) encountered an unexpected condition that prevented it from fulfilling the request by the client for access to the requested URL.
Basically something has gone wrong, but the server can not be more specific about the error condition in its response to the client. In addition to the 500 error notified back to the client, the Web server should generate some kind of internal error log which gives more details of what went wrong. It is up to the operators of the Web server site to locate and analyse these logs.
精彩评论