I have simple remote ejb client that calls remote stateless beans. There is security enabled on the server.
All is well for single threrad, authentication and authorization and remote call works:
final Properties jndiProperties = new Properties();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProperties.put(Context.SECURITY_PRINCIPAL, "XXX");
jndiProperties.put(Context.SECURITY_CREDENTIALS, "XXX");
jndiProperties.put("jboss.naming.client.ejb.context", true);
jndiProperties.put(Context.PROVIDER_URL, "remote://serverIP:4447");
jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
Context context = new InitialContext(jndiProperties);
RemoteService rs = (RemoteService)context.lookup("ejb:app/app-ejb-1.0-SNAPSHOT/RemoteBean!com.app.services.remoting.RemoteService");
rs.myMethod();
So far so good, authentication is OK and remote call works.
However, If i make remote call from another thread, like from event handler in GUI application, I get:
java.lang.IllegalStateException: No EJB receiver available for handling [appName:app,modulename:app-ejb-1.0-SNAPSHOT,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@12a55aa
I realised that reason for this is that EJB security context is thread local var and it is missing in all spawned threads. Am I right?
What am I supposed to do tao make secured EJB remote calls from event handlers?