[jax-rs-spec users] [jsr339-experts] Are Links build with fromReosurce or fromResourceMethod are useful at all?

From: Jan Algermissen <>
Date: Wed, 14 Nov 2012 11:29:57 +0100

Links that are constructed by using Link.fromResource or Link.fromResourceMethod come with a relative URI.

This URI is always relative to the JAX-RS application context.

If I am not completely out of my mind, these links are never useful as-is, because they are always relative in a way that doesn't fit any current resolution context.

At leat not without applying rewrite rules in front of the container.

E.g. suppose my app is living at

and my resources at

Now if I have

class OrderResource { ... }

class CustomerResource { ... }

and I do a GET on 'my' account:


What might come back is a response with a Link to the order service:

200 Ok
Link: <orders/service>;rel=...


This link would never resolve to:

but, (hope I get this right) to


Bottom line seems to be: the runtime should prepend the base URI and produce absolute links.

However(!) given that it is very unusual to have the actual base-URI as the publicly visible base URI (there is usually quite a bunch of mangling going on) producing an absolute URI does cut it either - in fact it would be worse.

Maybe we need to rethink the UriBuilder.fromXXX behavior to that regard, too.

Any ideas?