question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HttpServer tries and fails to create a Jetty HttpServer when defined by SPI

See original GitHub issue

The 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:closed
  • Created 6 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kagkarlssoncommented, Jan 10, 2018

Ok, sorry for being unclear!

As far as I can see, jmx_exporter uses HTTPServer from simpleclient_httpserver which technically uses the JDK’s HttpServerProvider.provider() to instantiate a HttpServer. HttpServerProvider uses the Java SPI-mechanism to determine what HttpServer implementation to instantiate, and in most cases that will be the built-in sun.net.httpserver.HttpServerImpl. However, since SPI is used, if I put a jetty-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.

0reactions
kagkarlssoncommented, Feb 15, 2018

For future readers, this issue is being fixed in Jetty: https://github.com/eclipse/jetty.project/issues/2114

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found