Registered Interceptor using EJBClientContext.registerInterceptor(..) is not called on EAP 6.1.0
sunil_dixit Jul 1, 2013 7:28 AMHi,
My requirement is to pass some additional information to security interceptors and do the same I am using " org.jboss.ejb.client.EJBClientContext.getCurrent().registerInterceptor()" for registering "EJBClientInterceptor" implementation.
It was working with EAP 6.0.1 version but now I have upgraded by jboss EAP 6.1.0 and it's never gets invoked before any EJBs (i.e. remote ejbs) gets invoked.
Here is remote client code
public static void callEJB() throws Exception {
Hashtable<String, Object> jndiProperties = new Hashtable<String, Object>();
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProperties.put(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming");
jndiProperties.put("jboss.naming.client.ejb.context", true);
jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");
jndiProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", false);
jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS",true);
jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS","JBOSS-LOCAL-USER");
jndiProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT",false);
InitialContext context = new InitialContext(jndiProperties);
registerClientCallBack(context);
String ejbJNDI = "HelloWorldEAR/HelloWorldEJB/HelloWorld!com.test.cl.HelloWorldRemote";
HelloWorldRemote remote = (HelloWorldRemote) context.lookup(ejbJNDI);
remote.sayHello();
}
private static void registerClientCallBack(){
org.jboss.ejb.client.EJBClientContext.getCurrent().registerInterceptor(0, new ClientSecurityInterceptor()); // registering the EJBClientInterceptor
}
EJBClientInterceptor code
public class ClientSecurityInterceptor implements EJBClientInterceptor {
public void handleInvocation(EJBClientInvocationContext context) throws Exception {
System.out.println("INSIDE CLIENT INTERCEPTOR");
context.sendRequest();
}
public Object handleInvocationResult(EJBClientInvocationContext context) throws Exception {
return context.getResult();
}
}
I have noticed one Strange problem in EAP 6.1.0
Earlier (i.e. in EAP 6.0.1) "org.jboss.ejb.client.EJBClientContext.getCurrent()" was throwing "NullPointerException" and we need to use following classes to make this work
EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(ejb3Props());
ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(selector);
org.jboss.ejb.client.EJBClientContext.getCurrent().registerInterceptor(0, new ClientSecurityInterceptor()); // registering the EJBClientInterceptor
Now in EAP 6.1.0 this behave in other manner and we don't need "EJBClientContext,EJBClientConfiguration,ContextSelector".
Thanks,
Sunil Dixit