EJB3 client interceptor not configured with EJBClientContext inside JBoss 6.2 EAP
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?
Regards,
Bernd
Responses
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?
Regarding
-
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 -
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 Bernd,
1) I think that is not true in any case :( -- I need to test it
2) AFAIK only if remoteIF is used
3)
- 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
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
