How can I lookup a secure EJB in a different application from a WAR in EAP6?
Issue
- EJBs are inside ear
- Client is in the war
- Both ear and war are deployed in JBoss EAP 6.3 app server.
- The war is running JunitEE tests
- The test lookup the EJB from the war
- Used the following Context lookup which throws an error.
- This same context lookup succeeds from a standalone client and we are able to invoke ejbs.
Context Lookup:
Properties clientProperties = new Properties();
clientProperties.put("remote.connections", "default");
clientProperties.put("remote.connection.default.port", "4447");
clientProperties.put("remote.connection.default.host", "127.0.0.1");
if (credential != null) {
clientProperties.put("remote.connection.default.username", credential.getUsername());
clientProperties.put("remote.connection.default.password", credential.getPassword());
}
clientProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
clientProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
clientProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
clientProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "${host.auth:JBOSS-LOCAL-USER}");
EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(clientProperties);
ContextSelector<EJBClientContext> contextSelector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(contextSelector);
Properties properties = new Properties();
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
context = new InitialContext(properties);
Error inside war:
13:58:08,715 ERROR [infrastructure.interfaces.util.ServiceLocator] (http-127.0.0.1/127.0.0.1:8080-1) Unable to lookup ejb:APP/business/OrgSession!enrolment.application.interfaces.facade.OrgFacade: java.lang.SecurityException: EJBCLIENT000021: EJB client context selector may not be changed
at org.jboss.ejb.client.EJBClientContext.setSelector(EJBClientContext.java:210) [jboss-ejb-client-1.0.25.Final-redhat-1.jar:1.0.25.Final-redhat-1]
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.3.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
