Troubles with JAX-RS Generation from RAML


I’m trying to use the JAX-RS generator.
It took me a while to understand the minimal set of maven dependencies to include for a war project since all examples assume you want to create a stand-alone application but at the end I got them right.
Now I have several problems with the code generator.

First: the generator insists on creating interfaces annotated with @Path. As per the JAX-RS specs (sect. 3.6) method annotations are inherited but nothing is said about class/interface annotations.
The specs also say “For consistency with other Java EE specifications, it is recommended to always repeat annotations instead of relying on annotation inheritance.” so it seems like the @Path in the interface is kind of useless.
I also deployed a simple example in wildfly and I can confirm that the @Path annotation MUST be explicitly repeated in the implementation class.

Second: how am I supposed to access path parameters in the implementation class? A resource like /foo/bar/{id} generates a getFooBar() method with no parameters,
all traces of {id} are lost).

Third: (related to the above) if I try to generate code from a very simple structure like that


I get an error because the generator tries to create two methods with the same signature:
It does not happen with the the raml file at examples/maven-examples/jaxb-example/src/main/resources/xml-model.raml because /animals and /animals/{id} generate different methods since the second one has parameters coming from the queryParameters.

To me either nobody is really using the JAX-RS generator or I’m using it in a wrong way (given the very terse documentation this is very much possible).
Anybody willing to help me with that? Any good real-world example of a project using the generator and any extended documentation available? Thanks.


Hi @RocketMan, would you mind creating an issue on the raml-for-jax-rs GitHub repository? You can include the example above as well as the command you’ve used to generate the code.


Hi, thanks for the reply.
I’m doing that, I’m a little hesitant since I do not know if these are bugs or operator errors…


No worries @RocketMan. Feel free to create a GitHub issue, if it’s not a bug, we’ll close it. At the very least however, I think we should fix the docs as it seems to be one of the reasons behind your struggle.