[jboss-user] [Installation, Configuration & DEPLOYMENT] - Re: 4.2.2 MBean getClientHost java.rmi.server.ServerNotActiv

guy_rouillier do-not-reply at jboss.com
Wed Aug 13 03:15:48 EDT 2008

Ok, I finally got this figured out.  For those who may stumble upon this thread, here is a quick summary of what I had to do to get this to work.  If someone can tell me where to post a code sample, I'll do that when I get some time:

(1) Implement a client interceptor that captures the client IP address in a static initialization block:

  | aIpAddr = InetAddress.getLocalHost().getHostAddress();

Then, in the invoke method, add this value to the invocation object:

  | invocation.setValue("client_ip_addr", aIpAddr);

This code runs in the client VM.

(2) Implement a container interceptor to copy the captured value into the server VM.  In order to have this value retrievable by an EJB and then by MBeans called by that EJB, you'll need a ThreadLocal variable.  In the code below ClientIpAddress manages a ThreadLocal variable.

  | String aIpAddr = (String) mi.getValue("client_ip_addr");
  | ClientIPAddress.set(aIpAddr);

(3) ThreadLocal variables are managed as class static variables, at least in my simple case (and in the Sun Java documentation.)  So, to use the value in an EJB or MBean, you just reference it.  This assumes the EJB and the MBean are running in the same VM.  If not, I suppose you'll have to figure out some way to pass along the value to the target VM, I imagine through another pair of invokers.

  | ClientIPAddress.get()

I'd like to say a sincere thanks to myself for helping me through this ;).

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170242#4170242

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170242

More information about the jboss-user mailing list