Remote ejb invocation between hosts
akoledzhikov Nov 28, 2011 11:26 AMI'm running JBoss 7.1.0Beta in domain mode, and I've decided to try the new remote ejb invocation using jndi lookup. Drawing inspiration from the ancient texts provided here https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI , I did the following changes to my servers in host.xml :
<servers>
<server name="server-one" group="main-server-group">
<!-- server-one inherits the default socket-group declared in the server-group -->
<jvm name="default">
</jvm>
</server>
<server name="server-two" group="main-server-group" auto-start="true">
<!-- server-two avoids port conflicts by incrementing the ports in
the default socket-group declared in the server-group -->
<socket-binding-group ref="standard-sockets" port-offset="150"/>
<jvm name="default">
<heap size="64m" max-size="256m"/>
</jvm>
<system-properties>
<property name="jboss.ejb.client.properties.file.path" value="conf/remote-ejb.properties"/>
</system-properties>
</server>
</servers>
And I blatantly copy/pasted the ejb-client.properties from your example - nothing changed there except the host name. Then I create my initial context and do the lookup/invocation like this:
Hashtable env = new Hashtable();
env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
Context ctx = new InitialContext(env);
SingletonCounterAccess access = (SingletonCounterAccess)ctx.lookup("java:global/ejb/SingletonCounterRemote");
access.increment();
The following code is executed in a mdb deployed in server two, and the port, specified in conf/remote-ejb.properties is for server one. Unfortunately, the execution of access.increment() also happens in server two. Am I doing something wrong, or the mechanism for ejb calls between hosts is different?
P.S. I've also tried passing some standard properties to the initial context:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:4447
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
and tried to make the lookup without the remote-ejb properties, but failed with:
javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:4447 [Root exception is javax.naming.CommunicationException: Failed to retrieve stub from server localhost:4447 [Root exception is java.io.StreamCorruptedException: invalid stream header: 0000000C]]