Weird exception in HttpDestination

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Weird exception in HttpDestination

makc
Hello.

So I followed this tutorial http://www.eclipse.org/jetty/documentation/current/http-client-api.html#http-client-blocking and wrote this two lines of code:

HttpClient client = new HttpClient();
ContentResponse response = client.GET("http://127.0.0.1:8080/index.html");

and I get this exception

java.lang.NullPointerException
        at org.eclipse.jetty.client.HttpDestination.<init>(HttpDestination.java:61)
        at org.eclipse.jetty.client.PoolingHttpDestination.<init>(PoolingHttpDestination.java:35)
        at org.eclipse.jetty.client.http.HttpDestinationOverHTTP.<init>(HttpDestinationOverHTTP.java:30)
        at org.eclipse.jetty.client.http.HttpClientTransportOverHTTP.newHttpDestination(HttpClientTransportOverHTTP.java:46)
        at org.eclipse.jetty.client.HttpClient.destinationFor(HttpClient.java:451)
        at org.eclipse.jetty.client.HttpClient.send(HttpClient.java:481)
        at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:606)
        at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:571)
        at org.eclipse.jetty.client.HttpClient.GET(HttpClient.java:327)
        at org.eclipse.jetty.client.HttpClient.GET(HttpClient.java:315)
        ...

HttpDestination.java:61 on github has this line:

this.exchanges = new BlockingArrayQueue<>(client.getMaxRequestsQueuedPerDestination());

so the client is null? but this is stable build from http://download.eclipse.org/jetty/stable-9/dist/, can't possibly have things like this broken?
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Weird exception in HttpDestination

makc
After looking at HttpClientTransportOverHTTP.java:46 I thought that maybe the client was not set, and tried to change the code to

            HttpClientTransportOverHTTP transport = new HttpClientTransportOverHTTP()
            HttpClient client = new HttpClient(transport, null);
            transport.setHttpClient(client);
            ContentResponse response = client.GET("http://127.0.0.1:8080/index.html");

it now gets me

java.util.concurrent.RejectedExecutionException: org.eclipse.jetty.client.HttpClient@517b46 is stopped
    at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:191)
    at org.eclipse.jetty.client.HttpClient.send(HttpClient.java:482)
    at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:606)
    at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:571)
    ...

so this shiny new client api just does not work, does it.

_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] Weird exception in HttpDestination

makc
duhhh, silly me, client needs to be started.

solved

_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users