fareed fareed - 9 months ago 65
Java Question

RESTeasy Name Binding Annotation Error in Eclipse

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:

@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Secured {

Authentication Filter:

public class AuthenticationAgent implements ContainerRequestFilter {

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.

enter image description here

Answer Source

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.