Search code examples
javaeclipsejax-rsresteasywildfly-10

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:

@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.

enter image description here


Solution

  • 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.