[jboss-user] [EJB3] - Passing information via InvocationContext in interceptors

Arjun Kumaar do-not-reply at jboss.com
Wed Jun 29 23:06:00 EDT 2011

Arjun Kumaar [http://community.jboss.org/people/arjun_kumaar] created the discussion

"Passing information via InvocationContext in interceptors"

To view the discussion, visit: http://community.jboss.org/message/612633#612633

Can I pass data in invocation context via remote method calls?
I have two stateless session beans
BeanA and BeanB

I have an interceptor for each bean

BeanAInterceptor for BeanA.methodA
BeanBInterceptor for BeanB.methodB

In BeanAInterceptor, I set some context data.
In BeanA.methodA, I get an handle to BeanB and call BeanB.methodB

In the process, BeanBInterceptor gets called and I want to read the context data
that I set in BeanAInterceptor, but I get null.

Is there any way to pass data via InvocationContext across remote calls if BeanA
and BeanB are deployed in 

a. same jvm
b. different jvm
c. in a clustered environment.

In short I want to send data across ejbs, but via interceptors and not 
as parameters to method calls.

I am pasting the relevant code below.

public class BeanA {    

    SessionContext ctx;

    public void methodA() {
        BeanBRemote bRemote = ctx


public class BeanAInterceptor {

    public Object interceptA(InvocationContext ctx) throws Exception {
        Map<String, Object> ctxData = ctx.getContextData();
        ctxData.put("key", "value");
        return ctx.proceed();


public class BeanB {

    public void methodB() {
        //do something


public class BeanBInterceptor {

    public Object interceptB(InvocationContext ctx) throws Exception {
        Map<String, Object> ctxData = ctx.getContextData();
        Object val = ctxData.get("key"); //I get val as null here
        return ctx.proceed();



Reply to this message by going to Community

Start a new discussion in EJB3 at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110629/7b154c28/attachment.html 

More information about the jboss-user mailing list