1

I need to start the local server using jetty drivers with java 11. I can start the server and access it with Java8, but with java 11 when I use curl command to check if the server is accessible it returns following:

$ 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>

Stack Trace

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]

As you can see I am using the Jetty 9.4.20.v20190813 version jars. Any idea what other things I should be looking into apart from jetty?

C.k.
  • 93
  • 2
  • 13
  • Use a proper URL. `http://localhost:8080/sample/site/URL/info` (fix the double `//`) – Joakim Erdfelt Nov 11 '19 at 12:39
  • We will need more information. Server startup logs perhaps? 503 is usually a hint that something is present, but didn't start. Jetty 9.4.x works great with all versions of Java from 8.0 thru Java 14. Every commit is even built and tested across Java 8, Java 11, and Java 13. – Joakim Erdfelt Nov 11 '19 at 12:43
  • Added the stacktrace from my logs – C.k. Nov 15 '19 at 06:37

1 Answers1

1

Jetty version

As you can see I am using the Jetty 9.4.20.v20190813 version jars. Any idea what other things I should be looking into apart from jetty?

Actually, your stacktrace says otherwise...

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

Jetty 9.2.x is EOL (End of Life).

See: https://www.eclipse.org/jetty/documentation/current/what-jetty-version.html

Support for Java 11 didn't land until Jetty 9.4.8

503 Cause according to your Stacktrace

The Status code 503 in your stacktrace comes from HttpURLConnection, not 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 Mismatch

Your stacktrace and your original question are using different URLs.

Original question

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

Stacktrace

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

How Jetty responds with 503

There are only a handful of places where Jetty itself will respond with a status code 503 (Service Unavailable). (all other status code 503 responses are from the Application and it's own libraries, not Jetty)

  1. Deployment failure - if your webapp failed to deploy, it will produce logs on the server side, during server startup, or webapp deployment telling why it failed to deploy. These failed webapps are responded to by a 503.
  2. Graceful shutdown of the server - when the server is told to shutdown, all requests that arrive in the narrow window of time between initiate of graceful shutdown and the server actually being shut down are responded to with a 503.
  3. DoSFilter - if using the Denial of Service prevention filter, requests that exceed the configured MaxRequestsMs will be responded to with a status code 503.
  4. Application servlets extending org.eclipse.jetty.servlets.DataRateLimitedServlet will respond to directory requests (those ending in /) with a status code 503. (no servlets or filters in Jetty itself use this Servlet)
  5. If your application throws a javax.servlet.UnavailableException during handling of a request

That's all of the 503 origins in Jetty itself.

The most common cause of 503 is a bad webapp deployment, and only the logs from your server side (during the deployment of your webapp) will help discover this state and the reason for it.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • Now as I looked deeper into the logs. I see that the server is not getting properly started. I see following error, regarding one of the file, ```Could not resolve placeholder 'tss.data' in string value "file:${tss.data}/idp/resources/conf/internal.xml"``` Any idea what causes this error? – C.k. Nov 18 '19 at 11:05
  • Got it. The project was trying to access the value of ```tss.data``` before the value is loaded. Yet I still face the same issue of HTTP:503 error. – C.k. Nov 20 '19 at 06:51
  • I have updated the all the packages with java 11 compatible versions as I am migrating the code from java 8 to java 11 platform. – C.k. Nov 20 '19 at 06:52