2013-10-07 51 views
0

ejb-jar.xml中包含在我的战争没有加载ejb-jar.xml中,当我打包的程序.ear ,我在的jboss-EAP-6.0.0里面使用/ maven3如何包括的.war

这里是我的.ear文件包含:

-- lib/other.jar 
-- mesejbs.jar (with META-INF/ejb-jar.xml) 
-- monwar.war (with WEB-INF/ejb-jar.xml) 

这里是mesejbs.jar/META-INF/ejb-jar.xml中

<?xml version="1.0" encoding="UTF-8"?> 
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"> 

    <interceptors> 
     <interceptor> 
      <interceptor-class>monpackage.ejb.log.LogInterceptor</interceptor-class> 
     </interceptor> 
    </interceptors> 

    <assembly-descriptor> 
     <interceptor-binding> 
      <ejb-name>*</ejb-name> 
      <interceptor-class>monpackage.ejb.log.LogInterceptor</interceptor-class> 
     </interceptor-binding> 
    </assembly-descriptor> 
</ejb-jar> 

LogInterceptor成功调用

这里是monwar.war/WEB-INF/ejb-jar.xml中

<?xml version="1.0" encoding="UTF-8"?> 
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"> 

    <interceptors> 
     <!-- default interceptors --> 
     <interceptor> 
      <interceptor-class>monpackage.web.interceptors.SecurityInterceptor</interceptor-class> 
     </interceptor> 
    </interceptors> 

    <assembly-descriptor> 
     <interceptor-binding> 
      <ejb-name>*</ejb-name> 
      <interceptor-class>monpackage.web.interceptors.SecurityInterceptor</interceptor-class> 
     </interceptor-binding> 
    </assembly-descriptor> 
</ejb-jar> 

但永远不会调用SecurityInterceptor!

如何激活SecurityInterceptor

+0

看看这里http://stackoverflow.com/questions/3336727/ejb-3-1 -application-deployed-as-war-only-what-about-ejb-jar-xml – rdcrng

+0

是的,但我的ejb-jar.xml位于WEB-INF目录中!如果我打包.war,一切都是正确的。但我需要打包耳朵:( – jboz

+0

对不起,如果我误解了。 – rdcrng

回答

0

我明白我的问题。 在战争中,ejb-jar.xml并非如此。这是对的。 对于ejbModule和webModule都没有启用CDI。 这里有一些解释:https://issues.jboss.org/browse/WELD-778

,所以我只是把我的ejbModule在我webModule这样的:

-- lib/other.jar 
-- monwar.war (with WEB-INF/ejb-jar.xml) 
    -- WEB-INF/lib/mesejbs.jar (with META-INF/ejb-jar.xml)