AbstractMethodError with URIBuilder

3,624 views
Skip to first unread message

Patrick Stearns

unread,
Oct 8, 2013, 11:21:24 AM10/8/13
to dropwiz...@googlegroups.com
I've set up a basic webservice using DropWizard and am attempting to write a client to connect to it.  I was following the example in the manual and came up with this:

        Client client = ClientBuilder.newClient();
        WebTarget webTarget = client.target("http://localhost:8080");
        WebTarget resourceWebTarget = webTarget.path("smallreview");
        Invocation.Builder invocationBuilder = resourceWebTarget.request(MediaType.TEXT_PLAIN_TYPE);
        Response response = invocationBuilder.get();
        System.out.println(response.readEntity(String.class));

This always bombs out with this exception:

java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
    at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
    at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:72)
    at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:180)
    at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:69)
    at com.productopia.ds.client.DSClient.getAllReviews(DSClient.java:20)

"DSClient.java:20" is the first WebTarget line in the first snippet.

I've done some Googling and the solutions posted all involve altering your dependencies or else making changes to a web.xml file.  There's no web.xml with DropWizard, and I'm not sure how to alter the dependencies without screwing everything up. 

Does anyone know a workaround or can point me to a solution?

Thanks, Patrick

Patrick Stearns

unread,
Oct 8, 2013, 11:33:28 AM10/8/13
to dropwiz...@googlegroups.com
Hurm, ok, figured it out myself.  Apparently using the glassfish-based example given in the manual doesn't work.  I had to drop this dependency given by the manual:

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.3.1</version>
        </dependency>

And add this one:

        <dependency>
            <groupId>com.yammer.dropwizard</groupId>
            <artifactId>dropwizard-client</artifactId>
            <version>0.6.2</version>
        </dependency>

And finally rewrite my code to replace the previous snippet with this:

        Client client = new Client();
        WebResource webResource = client.resource("http://localhost:8080/smallreview");
        String gotten = webResource.get(String.class);

And now it all works.  :)

Nick Telford

unread,
Oct 8, 2013, 11:47:07 AM10/8/13
to dropwiz...@googlegroups.com
Which manual is this? I can't find any mention of glassfish (dependency or otherwise) in the Dropwizard User Manual.

Patrick

unread,
Oct 8, 2013, 2:23:19 PM10/8/13
to dropwiz...@googlegroups.com
Ah, my bad - it's in the Jersey docs linked to by the manual, not the manual itself.  Sorry about that.

For the record, I was using the examples here: https://jersey.java.net/nonav/documentation/latest/user-guide.html#client-api


--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Lance N.

unread,
Oct 17, 2013, 10:44:21 PM10/17/13
to dropwiz...@googlegroups.com, patrick...@gmail.com
The DW manual happens to point to the Jersey 2.x site. DW uses Jersey 1.x. So, using the Jersey manual is a rather frustrating experience.
Reply all
Reply to author
Forward
0 new messages