My ejb-jar.xml contained in my war is not loaded when I package it inside an .ear that I use on jboss-eap-6.0.0/maven3

Here is what my .ear file contains:

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

Here is 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 is succcessfully invoked.

Here is 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>

but SecurityInterceptor is never invoked !

How do I activate SecurityInterceptor?

有帮助吗?

解决方案

I've understood my problem. It was not du to ejb-jar.xml in war. This is right. It's du to CDI that is not enabled for both ejbModule and webModule. Here are some explanations : https://issues.jboss.org/browse/WELD-778

so I just put my ejbModule in my webModule like this :

 -- lib/other.jar
 -- monwar.war (with WEB-INF/ejb-jar.xml)
     -- WEB-INF/lib/mesejbs.jar (with META-INF/ejb-jar.xml)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top