HttpServer tries and fails to create a Jetty HttpServer when defined by SPI
See original GitHub issueThe HTTPServer
will not start when using Jetty as HttpServerProvider
. Might be as easy as to call .create(addr,..)
directly, without call to bind(...)
.
Unless the intent is to always start a com.sun Server, then perhaps that should be done more explicitly.
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.NullPointerException
at org.eclipse.jetty.http.spi.JettyHttpServer.bind(JettyHttpServer.java:94)
at org.eclipse.jetty.http.spi.JettyHttpServerProvider.createHttpServer(JettyHttpServerProvider.java:69)
at com.sun.net.httpserver.HttpServer.create(HttpServer.java:130)
at com.sun.net.httpserver.HttpServer.create(HttpServer.java:105)
at io.prometheus.jmx.shaded.io.prometheus.client.exporter.HTTPServer.<init>(HTTPServer.java:144)
at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:38)
... 6 more
Versions: jmx_exporter: 0.1.0 simpleclient_httpserver: 0.1.0 (by transitive dependency)
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Embedded Jetty HttpServer not accepting mutipart/form-data
Some progress. It no longer throws errors, but it still returns the 415 http error. I'm thinking I'm missing an annotation in the...
Read more >Eclipse Jetty: Operations Guide
Jetty is an HTTP server and Servlet Container, and supports deployments of web applications. The Jetty server listens on one or more network ......
Read more >Error while loading class org.springframework.http.server ...
Api_service_1 | Caused by: org.jboss.weld.resources.spi.ResourceLoadingException: Error while loading class org.springframework.
Read more >Chapter 4. Application Deployment and Runtime Environments
Creating new Jersey-enabled jdk http server is as easy as: ... We will not look into Jetty's capabilities as a Servlet container (although...
Read more >Chapter 3. Securing the Jetty HTTP Server Red Hat AMQ 6.3
Before you can enable SSL, you must create an X.509 certificate and private key for the Web console. The certificate and private key...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, sorry for being unclear!
As far as I can see, jmx_exporter uses
HTTPServer
fromsimpleclient_httpserver
which technically uses the JDK’sHttpServerProvider.provider()
to instantiate aHttpServer
.HttpServerProvider
uses the Java SPI-mechanism to determine whatHttpServer
implementation to instantiate, and in most cases that will be the built-insun.net.httpserver.HttpServerImpl
. However, since SPI is used, if I put ajetty-http-spi
dependency on the classpath, it will instead try to instantiate a Jetty-httpserver, which fails.So it is a pretty edgy case. We are using
jetty-http-spi
in our application to expose RMI services over Jetty. Ultimately, we would just like to get the jmx_exporter to work in our app, but after looking at the possibilities, I am not clear on how we can achieve that in our current setup.For future readers, this issue is being fixed in Jetty: https://github.com/eclipse/jetty.project/issues/2114