我正在测试/切换到
Java EE7(Glassfish 4),我遇到的一个问题是拦截器,每当我尝试运行项目时,我都会收到以下错误.
SEVERE: Exception while loading the app : CDI deployment
@H_502_9@
failure:WELD-001417 Enabled interceptor class
com.xxxxxx.security.SecuredInterceptor in
file:/home/xxxxxx/xxxxxx/target/xxxxxx/WEB-INF/beans.xml@7 is neither
annotated @Interceptor nor registered through a portable extension我正在看CDI 1.1规范的1.3.6节,看起来没有任何改变,所以我做错了什么?
这是我正在使用的代码;
@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 { // Do Stuff } }<?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>