EJB invocation from a remote server instance - SaslException
tc7 Mar 19, 2012 11:18 PMI'm having trouble accessing a remote EJB between jboss app server instances.
I've followed the example at https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+server+instance, but have been unable to make this work.
Both servers are running JBoss-7.1.1.Final Brontes.
I have no trouble accessing the remote EJB from a "remote client" (i.e. not a JBoss instance), however there appears to be an authentication issue between the app servers.
For this example Server A hosts the EJBs and Server B attempt to connect remotely in order to invoke the EJB.
1. Configuration
a) Server A
i) runtime parameter
-Djboss.node.name=serverA
ii) CostingServiceEJB implements following
package com.myapp.costing.ejb;
@Remote
public interface CostingService
{
public String ping(String costDomain) throws RemoteException;
}
iii) CostingServiceEJB and associated classes deployed as:
MyAppCosting.war within MyCosting.ear
b) Server B
i) no jboss-ejb-client.properties
ii) jboss-ejb-client.xml
<jboss-ejb-client xmlns="urn:jboss:ejb-client:1.0">
<client-context>
<ejb-receivers>
<remoting-ejb-receiver outbound-connection-ref="remote-ejb-connection"/>
</ejb-receivers>
</client-context>
</jboss-ejb-client>
iii) standalone-full.xml
<subsystem xmlns="urn:jboss:domain:remoting:1.1">
<connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>
<outbound-connections>
<remote-outbound-connection name="remote-ejb-connection" outbound-socket-binding-ref="remote-ejb-binding" security-realm="ApplicationRealm">
<properties>
<property name="SSL_ENABLED" value="false"/>
<property name="SASL_POLICY_NOANONYMOUS" value="false"/>
<!--<property name="SASL_POLICY_NOPLAINTEXT" value="false"/>-->
</properties>
</remote-outbound-connection>
</outbound-connections>
</subsystem>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<outbound-socket-binding name="remote-ejb-binding">
<remote-destination host="<remote-host-ip-addr>" port="4447"/>
</outbound-socket-binding>
</socket-binding>
c) remote client (run in a Java VM from eclipse with the necessary JBoss jars)
followed procedure at:
https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
i) jboss-ejb-client.properties
remote.connections=default
endpoint.name=client-endpoint
remote.connection.default.port = 4447
remote.connection.default.host=<remote-host-ip-address>
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username = <remote-username>
remote.connection.default.password = <remote-password>
ii) eclipse runtime config
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<eclipse-userlibraries version="2">
<library name="jboss-ejb-client" systemlibrary="false">
<archive path="/opt/jboss-7-one/modules/org/jboss/sasl/main/jboss-sasl-1.0.0.Final.jar"/>
<archive path="/opt/jboss-as-7.1.0.Final/modules/javax/transaction/api/main/jboss-transaction-api_1.1_spec-1.0.0.Final.jar"/>
<archive path="/opt/jboss-as-7.1.0.Final/modules/javax/ejb/api/main/jboss-ejb-api_3.1_spec-1.0.1.Final.jar"/>
<archive path="/opt/jboss-as-7.1.0.Final/modules/org/jboss/ejb-client/main/jboss-ejb-client-1.0.2.Final.jar"/>
<archive path="/opt/jboss-as-7.1.0.Final/modules/org/jboss/marshalling/main/jboss-marshalling-1.3.9.GA.jar"/>
<archive path="/opt/jboss-as-7.1.0.Final/modules/org/jboss/xnio/nio/main/xnio-nio-3.0.3.GA.jar"/>
<archive path="/opt/jboss-as-7.1.0.Final/modules/org/jboss/remoting3/main/jboss-remoting-3.2.2.GA.jar"/>
<archive path="/opt/jboss-as-7.1.0.Final/modules/org/jboss/logging/main/jboss-logging-3.1.0.GA.jar"/>
<archive path="/opt/jboss-as-7.1.0.Final/modules/org/jboss/marshalling/river/main/jboss-marshalling-river-1.3.9.GA.jar"/>
<archive path="/opt/jboss-as-7.1.0.Final/modules/org/jboss/xnio/main/xnio-api-3.0.3.GA.jar"/>
</library>
</eclipse-userlibraries>
2. EJB Lookup
2a: EJB lookup from server B
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProperties.put(Context.SECURITY_PRINCIPAL, "<remote-user-name>");
jndiProperties.put(Context.SECURITY_CREDENTIALS, "<remote-password>");
final Context context = new InitialContext(jndiProperties);
...
//String lookupName = "ejb:MyCosting/MyAppCosting//CostingServiceEJB!com.myapp.costing.ejb.CostingService";
String lookupName = "ejb:MyCosting/MyAppCosting/serverA/CostingServiceEJB!com.myapp.costing.ejb.CostingService";
log.debug("EJB Lookup name: " + lookupName);
CostingService svc = (CostingService) context.lookup(lookupName);
svc.ping();
result
20120320 13:06:34,611 ERROR [org.jboss.remoting.remote.connection] (Remoting "myapp" read-1) JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
20120320 13:06:34,902 ERROR [org.jboss.remoting.remote.connection] (Remoting "myapp" read-1) JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
20120320 13:06:34,904 ERROR [com.myapp.project.solution.generation.plugin.costing.GMPreprintCostingPlugin] (Solution Generator 1) Error running Generic Material Preprint Costing Plugin: java.lang.IllegalStateException: No EJB receiver available for handling [appName:MyCosting,modulename:MyAppCosting,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@4fb54562: java.lang.IllegalStateException: No EJB receiver available for handling [appName:MyCosting,modulename:MyAppCosting,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@4fb54562
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
at $Proxy21.ping(Unknown Source) at com.myapp.costing.ejb.CostingServiceEJBLocator.getCostingService(CostingServiceEJBLocator.java:141) [MyAppIntegration.jar:]
...
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_01]
2b: Alternative lookup
As above, but tried adding:
jndiProperties.put("jboss.naming.client.ejb.context", "true");
jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
jndiProperties.put("jboss.naming.client.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
result (as above)
2c: EJB lookup from standalone client
result
Using the same jndi properities as 2a above this works every time.
I'm not sure what I've missed, but am unable to get JBoss server to JBoss server ejb invocation working.
Can anyone see what I'm doing wrong, or recommend a solution?
I should also add that the EJB invocation works fine when the EJB ear is deployed within the same server as the caller (i.e. also deployed on server B).
tc