Default interceptors, such as application security interceptors, must be listed in the ejb-jar.xml
file, or they will not be treated
as default.
This rule applies to projects that contain JEE Beans (any one of javax.ejb.Singleton
, MessageDriven
,
Stateless
or Stateful
).
Noncompliant Code Example
// file: ejb-interceptors.xml
<assembly-descriptor>
<interceptor-binding> <!-- should be declared in ejb-jar.xml -->
<ejb-name>*</ejb-name>
<interceptor-class>com.myco.ImportantInterceptor</interceptor-class> <!-- Noncompliant; will NOT be treated as default -->
</interceptor-binding>
</assembly-descriptor>
Compliant Solution
// file: ejb-jar.xml
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
<interceptor-class>com.myco.ImportantInterceptor</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
See