We developed a training application which contains a standalone java clients communicating with EJBs. The working setup included a JBoss AS 7.1 on Windows 7 and an application user created via /bin/add-user.bat.
The client was coded like that:
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProps.put("jboss.naming.client.ejb.context", true);
jndiProps.put(Context.PROVIDER_URL, "remote://localhost:4447");
jndiProps.put(Context.SECURITY_PRINCIPAL, "user");
jndiProps.put(Context.SECURITY_CREDENTIALS, "xxx");
Context ctx = new InitialContext(jndiProps);
MyBeanRemote myBean = (MyBeanRemote) ctx.lookup("ejb:/training//MyBean!mypackage.MyBeanRemote");
String result = myBean.greet("John");
The client was started with jboss-client.jar in the classpath.
Now we tried to use a WildFly 8.1 instead which deployed successfully, but the client fails with
Exception in thread "main" java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:, moduleName:syjeews, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@6e7d3146
Changing the JNDI lookup name into something which is printed out during deployment (e.g. java:global/training/MyBean!mypackage.MyBeanRemote
) resulted in
Exception in thread "main" javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [remote://localhost:4447 (java.net.ConnectException: Connection refused: no further information)]
After searching googling for a while we stumpled upon several articles on SO (e.g. this or that) or samples or the Wildfly Developer Guide, but all alternatives, may it be the minimal JNDI properties or the extended configuration via ClientContext didn't make it work.
So my question is, what needs to be done to migrate the code/configuration above to run it under WildFly?
Note: This is not production code, so security is not an issue - if I can simplify the whole configuration, it's fine - it should only demonstrate how to use an EJB remote interface from a standalone Java program.