Reputation: 3082
I'm trying to bind a name to a filter in JAX-RS so I can secure some methods in the rest service as the following:
Secured Name Binding:
@NameBinding
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Secured {
}
Authentication Filter:
@Secured
@Provider
@Priority(Priorities.AUTHENTICATION)
public class AuthenticationAgent implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
//do something
}
}
However, eclipse is giving me this error when I'm adding the secured annotation to my filter.
There is no JAX-RS application, resource or resource method with this name binding annotation.
Upvotes: 4
Views: 1748
Reputation: 91
These types of error are not really big errors. For this type of error on JAX-RS we can mark it as a warning or ignore it at all.
For Eclipse, go to Window > Preferences > Jboss Tools > JAX-RS > JAX-RS Validator > JAX-RS Name Bindings
and set Missing @Retention annotation
to something other than "Error". (Yes, the preference name is misleading).
(To customize it for a specific project, click on Configure Project Specific Settings...
in the top right corner)
Upvotes: 3
Reputation: 209052
It's not really an error that will stop JAX-RS from working. It's more of just a warning (specific to that editor).
Name Binding should only be used when you want to limit the filter to resources classes/methods also annotated with the name binding annotation. If this is the case, then annotate the classes/methods you want to go through that filter. If you want everything to go through the filter, then forget the annotation altogether. Just get rid of it.
Upvotes: 2