JBoss 7 remote JNDI
s3lvatico Jan 21, 2012 6:28 PMHello everyone,
I'm trying to carry out some simple experiments in accessing an EJB's remote view from a client.
I (seem to have) followed all the instructions in the document https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI ,
with the only difference being the fact that I boiled down the remote interface to a single adder method, like this:
public interface RemoteAdder { int add(int x, int y); }
....and the implementing bean
import javax.ejb.Remote; import javax.ejb.Stateless; @Stateless @Remote(RemoteAdder.class) public class AdderBean implements RemoteAdder { @Override public int add(int x, int y) { return x + y ; } }
The deployment goes fine:
00:09:39,674 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 2) JBAS015003: Found LeEJBon7.jar in deployment directory. To trigger deployment create a f
ile called LeEJBon7.jar.dodeploy
00:09:39,674 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) Starting deployment of "LeEJBon7.jar"
00:09:39,704 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named AdderBean in deplo
yment unit deployment "LeEJBon7.jar" are as follows:
java:global/LeEJBon7/AdderBean!org.gmnz.as7.RemoteAdder
java:app/LeEJBon7/AdderBean!org.gmnz.as7.RemoteAdder
java:module/AdderBean!org.gmnz.as7.RemoteAdder
java:global/LeEJBon7/AdderBean
java:app/LeEJBon7/AdderBean
java:module/AdderBean
00:09:39,724 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018559: Deployed "LeEJBon7.jar"
The client code looks ludicrously simple:
import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; public class LeRemote { public static void main(String[] args) { Properties jndiProps = new Properties(); jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); try { InitialContext context = new InitialContext(jndiProps); final String appName = ""; final String moduleName = "LeEJBon7"; final String distinctName = ""; final String beanName = AdderBean.class.getSimpleName(); final String viewClassName = RemoteAdder.class.getName(); RemoteAdder adderEjb = (RemoteAdder) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName); int x = adderEjb.add(3, 5); System.out.println(x); } catch (NamingException e) { e.printStackTrace(); } } }
The client is located in a simple java project with the required jar for remoting configured as an Eclipse user library:
...and here's the required properties file:
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=localhost
remote.connection.default.port=4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
Still, when I run the client I get this error output on the client side:
INFO: XNIO NIO Implementation Version 3.0.0.CR5
22-gen-2012 0.23.09 org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.0.CR6
22-gen-2012 0.23.09 org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 1 and marshalling strategies [river]
22-gen-2012 0.23.09 org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context org.jboss.ejb.client.EJBReceiverContext@5e0feb48 on channel Channel ID c1219afb (outbound) of Remoting connection 6ee0a386 to localhost/127.0.0.1:4447
22-gen-2012 0.23.09 org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleEnd
INFO: Channel Channel ID c1219afb (outbound) of Remoting connection 6ee0a386 to localhost/127.0.0.1:4447 can no longer process messages
Exception in thread "main" java.lang.NullPointerException
at org.jboss.ejb.client.remoting.ChannelAssociation$UnusableChannelResultProducer.getResult(ChannelAssociation.java:323)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:212)
at org.jboss.ejb.client.remoting.RemotingTransactionInterceptor.handleInvocationResult(RemotingTransactionInterceptor.java:45)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:214)
at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:51)
at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:214)
at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:337)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:117)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:96)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:86)
at $Proxy0.add(Unknown Source)
at org.gmnz.as7.LeRemote.main(LeRemote.java:24)
and this one on the server side:
00:23:09,603 ERROR [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] (Remoting "hagakure" task-4) Exception on channel Channel ID 41219afb (inbound)
of Remoting connection 59e5ffbd to /127.0.0.1:51632 from message org.jboss.remoting3.remote.InboundMessage$3@539530aa: java.io.IOException: Unsupported protocol version 0
at org.jboss.marshalling.river.RiverUnmarshaller.start(RiverUnmarshaller.java:1184)
at org.jboss.as.ejb3.remote.protocol.versionone.AbstractMessageHandler.prepareForUnMarshalling(AbstractMessageHandler.java:235)
at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.processMessage(MethodInvocationMessageHandler.java:101)
at org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver.handleMessage(VersionOneProtocolChannelReceiver.java:147)
at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:409) [jboss-remoting-3.2.0.CR8.jar:3.2.0.CR8]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]
00:23:09,927 ERROR [org.jboss.remoting.remote] (Remoting "hagakure" read-1) JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote host
Can't really figure out what's wrong.
Thanks in advance for every hint.