如何在Java11中使用码头驱动程序来解决HTTP:503服务不可用错误?

我需要使用带有Java 11的码头驱动程序来启动本地服务器。 我可以启动服务器并使用Java8来访问它,但是当我使用curl命令检查服务器是否可访问时,可以使用java 11来返回它:

 <select id="category" type="text" class="form-control">
        <option value=""></option>
        <option *ngFor="let c of categories$ | async" [value]="c.$key">
          {{ c.name }}
        </option>
    </select>

堆栈跟踪

$ curl http://localhost:8080//sample/site/URL/info
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 503 Service Unavailable</title>
</head>
<body><h2>HTTP ERROR 503</h2>
<p>Problem accessing /sample/site/URL/info. Reason:
<pre>    Service Unavailable</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.20.v20190813</a><hr/>

</body>
</html>

您可以看到我正在使用java.io.IOException: Server returned HTTP response code: 503 for URL: http://localhost:8080/idp/idpservice/register at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894) ~[na:1.8.0_192] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492) ~[na:1.8.0_192] at sun.reflect.NativeMethodaccessorImpl.invoke0(Native Method) ~[na:1.8.0_192] at sun.reflect.NativeMethodaccessorImpl.invoke(NativeMethodaccessorImpl.java:62) ~[na:1.8.0_192] at sun.reflect.DelegatingMethodaccessorImpl.invoke(DelegatingMethodaccessorImpl.java:43) ~[na:1.8.0_192] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_192] at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [javax.servlet-api-3.1.0.jar!/:na] at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808) [jetty-servlet-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) [jetty-servlet-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577) [jetty-security-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [jetty-servlet-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.Server.handle(Server.java:497) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [jetty-server-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [jetty-io-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [jetty-util-9.2.9.v20150224.jar!/:na] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [jetty-util-9.2.9.v20150224.jar!/:na] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_192] 版jar。 知道除了码头我还应该考虑什么?

endwar 回答:如何在Java11中使用码头驱动程序来解决HTTP:503服务不可用错误?

码头版本

  

如您所见,我正在使用Jetty 9.4.20.v20190813版本的jar。知道除了码头我还应该考虑什么?

实际上,您的stacktrace表示否则...

... .run(QueuedThreadPool.java:555) [jetty-util-9.2.9.v20150224.jar!/:na]

Jetty 9.2.x是停产期(EOL)。

请参阅:https://www.eclipse.org/jetty/documentation/current/what-jetty-version.html

直到Jetty 9.4.8才提供对Java 11的支持

503原因取决于您的堆栈跟踪

堆栈跟踪中的状态码503来自HttpURLConnection,而不是Jetty。

java.io.IOException: Server returned HTTP response code: 503 for URL: http://localhost:8080/idp/idpservice/register
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894) ~[na:1.8.0_192]
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492) ~[na:1.8.0_192]

URL不匹配

您的堆栈跟踪和原始问题使用的是不同的URL。

原始问题

http://localhost:8080//sample/site/URL/info

Stacktrace

http://localhost:8080/idp/idpservice/register

码头如何回应503

在少数地方,Jetty本身会以状态代码503(服务不可用)进行响应。 (所有其他状态代码503响应均来自该应用程序,并且是其自己的库,而不是Jetty)

  1. 部署失败-如果您的webapp部署失败,它将在服务器启动,服务器启动或webapp部署期间在服务器端生成日志,告知其部署失败的原因。这些失败的Web应用由503响应。
  2. 服务器的正常关闭-当服务器被告知关闭时,所有在启动正常关闭与实际关闭服务器之间的狭窄时间内到达的请求均以503响应。
  3. DoSFilter-如果使用“拒绝服务阻止”过滤器,则超过配置的MaxRequestsMs的请求将以状态代码503进行响应。
  4. 扩展org.eclipse.jetty.servlets.DataRateLimitedServlet的应用程序servlet将以状态码503响应目录请求(以/结尾的目录请求。(Jetty中没有servlet或过滤器本身使用此Servlet)
  5. 如果您的应用在处理请求期间抛出javax.servlet.UnavailableException

这就是Jetty本身的503个起源。

503的最常见原因是webapp部署不正确,只有服务器端的日志(在webapp部署期间)才能帮助发现此状态及其原因。

本文链接:https://www.f2er.com/3126546.html

大家都在问