An interceptor for lifecycle callbacks may only declare interceptor binding types that are defined as @Target(TYPE)

This rule flags @Target values other than ElementType.TYPE on custom annotations that meet the following conditions:

The following are lifecycle interceptor annotations:

The following example does not comply with the Java EE 7 Contexts and Dependency Injection (CDI) 1.2 specification but was tolerated in the CDI 1.0 implementation, which is based on the Apache OpenWebBeans implementation. In CDI 1.2, which is based on the Weld implementation, the application does not start.


@InterceptorBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface MyIInterceptorBinding {}


@Interceptor 
@MyIInterceptorBinding
public class MyIInterceptor {

   @PostActivate
   void postActivate (InvocationContext inv)

   @PreDestroy
   void preDestroy (InvocationContext inv)
}

To resolve this issue, remove the ElementType.METHOD from the @Target annotation, and remove all references to the annotation on application methods. If any element types other than ElementType.TYPE are specified, they must also be removed.

For more information about the Java EE 7 CDI 1.2 implementation, see Contexts and Dependency Injection 1.2 behavior changes.