EJB3 client interceptor not configured with EJBClientContext inside JBoss 6.2 EAP

Latest response

I wanted to use a symmetric client and server side EJB3 container interceptor as supposed in JBoss quickstart ejb-security-interceptors. For demonstration purpose, I implemented a small bean jar with BeanA and BeanB (SLSBs) using the same remote interface. BeanA is called from a remote client. Bean A is delegating the call to BeanB.

Assembly looks like this:

interceptortest.jar | |- META-INF | | | |- services | | | |- org.jboss.ejb.client.EJBClientInterceptor | |- mypackage | |- Bean |- BeanAImpl |- BeanBImpl |- BeanClientInterceptor

With BeanA invoking BeanB, the client interceptor is not called. I realized, that the EJBClientContext used, has been created upon JBoss startup, not during deployment.

While debugging, I stopped within the business method of BeanA and tried:
- EJBClientContext.getCurrent() : clientInterceptorsInClasspath is empty
- EJBClientContext.create() : clientInterceptorsInClasspath is empty
- EJBClientContext.create(contextClassLoader) : clientInterceptorsInClasspath is holding my custom client interceptor

Questions are:
1. Is this the expected behavior?
2. How can I use client interceptors within JBoss?
3. Do client interceptors only work with outbound connections?
4. Can I create custom, scoped EJBClientContext instances to use inside JBoss?




It looks like you have to register the client side interceptor. See the section "How to register an EJB client interceptor" in the following Knowledge Base Article [1] and let us know if that helps.

[1] https://access.redhat.com/site/solutions/315803

Hi Mustafa,

thanks for your quick response.

I read this article, but it didn't help much with my requirements.

  1. I need container interceptors, so EJB interceptors won't fit.
  2. I tried the service loader machanism (look at the assembly above), but it doesn't work, because the EJBClientContext used has been created before bean deployment, therefore without my interceptor.
  3. I tried adding my interceptor programmatically to the EJBClientContext.getCurrent() context. It worked for my litte example, but it would probably break other bean invocations, because other beans will probably use the same (global?) EJBClientContext, now with my custom interceptor configured, which is deployed with this bean JAR only.

Did the section on "JBoss "container interceptors" (JBoss EAP 6.1 and later)" in the same article not help?

Not at all. This sections is describing server side interceptors. I am using server side interceptors, too, and it looks like they work as expected.

But the counterpart, the client side interceptor, is working on a remote client calling an EJB and is working in JBoss when calling a remote EJB as described in JBoss quickstart ejb-security-interceptors using an outbound connection.

But the client side interceptor is not working on bean2bean calls (remote interface to a SLSB) within one server.

I would appreciate, if someone could answer my four questions above.

Hi Bernd, have you raised a support case for this? I think it will need some of our EJB specialists to look in to this in some detail and perhaps take a look at a reproducer.

Thanks for your help. I will file a support case.

Hi Bernd,
you might have a look to my github repository and the ejb-multi-server quickstart (which is a part of the eap-quickstarts).

There is a branch where I add a EJB Interceptor which is used in a EJB-EJB call from server to server.
See the last commit https://github.com/wfink/jboss-eap-quickstarts/commit/61f4cfc1dbc919109b0515e5c8374e2441dcdac0
for this branch https://github.com/wfink/jboss-eap-quickstarts/commits/mserver_AppMainwithClientInterceptor

Is that what you are looking for?


  1. Do client interceptors only work with outbound connections?
    That depends, only if the ejb-client library is involved this will work, for invocations with local interfaces it is not possible ATM

  2. Can I create custom, scoped EJBClientContext instances to use inside JBoss?
    Yes, but you might have some other issues here. I.e. if the IC is closed inside the method the transaction must be finished before you return.

Hi Wolf-Dieter,

thanks for your response.

I will take a look at your github repository. Even Darrans ejb-security-interceptors quickstart is working with client side interceptors in JBoss, but he is using server2server communication, too, therefore an outbound connection which is using an EJBClientContext created during deployment.

With my example, my SLSB, called from a remote client, is delegating to another SLSBs remote interface view. The client interceptor is not called. Does this mean "the ejb-client library is not involved" with this call?

My investigations showed, that an EJBClientContext created at JBoss startup (before my application was deployed) is used for this delegating call.
Might this be an issue? Should the client interceptor be called on bean2bean calls for remote interface view within the same server?

To clarify what I wanted to do: we are passing securty related information with every bean call. This was done using the JBoss' ClientLoginModule and a custom principal before JBoss 7. This worked with every EJB call and delegations, no matter if a remote client was calling a server, it worked with bean2bean calls in one server and it worked with bean2bean calls to other servers.

The ClientLoginModule is not supported any more. Darrans quickstart shows how to handle this with client and server interceptors. But this leads me to my questions...

Again the remaining question:
1. Should the client interceptor be involved when a remote interface view of an EJB is called within one server? Or with bean2bean calls for remote EJBS within one server depending on the applications assemble (e.g. in different JARs, WARs, EARs)?
2. Or: what kind of calls are "involing the ejb-client library"?
3. Shouldn't every deployment (bean jar or at least WAR or EAR) have its own, container managed and scoped EJBClientContext?
4. How does JBoss 7 handle EJBClientContext usage (creation, scoping, configuration) internally? Is there some documentation available?



(I forgot: using custom scoped EJBClientContext instances is not really what I want, since I expect even more issues like the transactional you mentioned above)

Hi Bernd,

1) I think that is not true in any case :( -- I need to test it
2) AFAIK only if remoteIF is used
- You will have a default EJBClientContext if nothing else is specified
- If the jboss-ejb-client.xml is in you app you will get your own EJBClientContext
- If you open a scoped-context the EJBClientContext is wired to the InitialContext and need to be handled by the app, there are some Knowledgebase articles around
4) unfortunately not much, the community (wildFly) contains something spread over the different EJB invocation chapters, this is IIRC the up to date one

Let me know if you need further help, maybe you open a case for this as mentioned before