通过ejb-jar.xml和beans.xml声明拦截器时,运行Widlfy时出错

时间:2018-06-21 06:12:32

标签: ejb interceptor

我想使用xml定义拦截器。 我已经声明了ejb-jar.xml,它以以下方式出现在src / main / resources / META-INF中:

<assembly-descriptor>
        <interceptor-binding>
            <ejb-name>packageA.ClassA</ejb-name>
            <interceptor-class>packageC.InterceptorA</interceptor-class>
            <method>
                <method-name>add</method-name>
            </method>
        </interceptor-binding>
    </assembly-descriptor>

这是我的beans.xml,它存在于src / main / webapp / WEB-INF中:

 <?xml version="1.0" encoding="UTF-8"?>
<!-- This file can be an empty text file (0 bytes) -->
<!-- We're declaring the schema to save you time if you do have to configure 
   this in the future -->
<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>packageC.InterceptorA</class>
        </interceptors>
</beans>

尽管项目构建成功,但是当我尝试在Wildfly中运行项目时,InterceptorAnnotationProcess.java却出现错误

Interceptor类的定义如下:

@Interceptor
@Dependent
public class InterceptorA {
@AroundInvoke
public Object method(Invocation Context ctx) {

}

}

该方法有问题吗?

0 个答案:

没有答案