I have a really simple JAX-RS service:
@Path("/test")
public class Service {
@Inject
@Message
String thingie;
@GET
public String test(){
return thingie;
}
}
Where that String comes out of a @Produces annotated method:
public class Producer {
@Produces
@Message
public String thingie(){
return "thingie";
}
}
The @Message qualifier looks like this:
@Qualifier
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
public @interface Message {
}
For completeness, the other code I have is a JAX-RS Activator class:
@ApplicationPath("/rest")
public class JAXRSActivator extends Application {
}
And an empty beans.xml. The app server I am using is Wildfly 10.0.10.
When I make a GET to /rest/test I get a response of 500, with the content type of plain/text and the text of "java.lang.NullPointerException". But no further info in the log or the message (specifically not the location that the NPE comes from).
My producer method gets invoked, but my test() method in the Service class does not.
It works fine using @Named("message") instead of @Message, so what have I missed?
tldr; put @Message in a package.
So, as you might guess this was a toy example to test something out, and I threw it all in the default package.
The Hibernate validator doesn't deal with annotations in the default package, in that it assumes that there will be a package.