I am testing / switching to Java EE7 (Glassfish 4), and one of the problems that I have with Interceptors, whenever I try to start a project, I get the following error.
SEVERE: application loading exception: CDI deployment failure: WELD-001417 The interceptor class com.xxxxxx.security.SecuredInterceptor in file: / home / xxxxxx / xxxxxx / target / xxxxxx / WEB-INF / beans.xml @ 7 is neither annotated @Interceptor and not registered via portable extension
I look at section 1.3.6 of the CDI 1.1 specification, it doesnβt look like something has changed, so what am I doing wrong?
Here is the code I'm using;
@InterceptorBinding @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) public @interface Secured {}
@Secured @Interceptor public class SecuredInterceptor implements Serializable { @AroundInvoke public Object interceptSecured(InvocationContext ic) throws Exception {
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="annotated"> <interceptors> <class>com.xxxxxx.security.SecuredInterceptor</class> </interceptors> </beans>
source share