Red Hat Customer Portal

Skip to main content

Is it possible to configure EJB Interceptors server-wide in EAP 6?

Solution Verified - Updated -

Environment

Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x

Issue

  • For doing logging as well as some attribute propagation on every (remote) ejb call, need to define a global default interceptor in the container.
  • The EJB Interceptor would apply to any application deployed in the EJB Container.
  • The deployed applications should not define their own interceptors in the ejb-jar.xml.
  • How can a EJB Interceptor be defined in a Module ?
  • Is there an alternative method that can be called after onMessage.

Resolution

EJB interceptors are defined at three levels,

  1. Default Level -- This is typically done in the ejb-jar.xml file, which is largely the application scope.
  2. Class Level --- This is done by including the @Interceptors annotation at the class level.
  3. Method Level -- This is done by declaring @Interceptors at the method level.

EJB interceptors always require one of the above to be configured in order for them to be invoked. You cannot avoid declaring them in ejb-jar.xml as that is required to trigger the interceptor.

There is currently no mechanism to define EJB interceptors server or EAR-wide.

Related articles
EJB client interceptors in JBoss EAP 6
Implementing Server Side EJB 3 Interceptors in JBoss EAP 6

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.