glassfish – Java EE7的拦截器问题
我正在测试/切换到
Java EE7(Glassfish 4),我遇到的一个问题是拦截器,每当我尝试运行项目时,我都会收到以下错误.
我正在看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> 解决方法
来自CDI规范的第12.1节.
您的1.1版beans.xml具有bean-discovery-mode =“annotated”.将beans.xml更改为bean-discovery-mode =“all”,我的猜测是它会像从beans.xml中删除版本并使用旧命名空间一样工作,就像在CDI 1.0中一样. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |