I know there are some similar questions here, but I still can not find a solution. I have two JBoss AS 7.0 servers running in the same machine, namely A and B.
A, is the server and provides this service:
15:49:02,998 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-4) JNDI bindings for session bean named QuartzManagerBean in deployment unit subdeployment "Foo-Services.jar" of deployment "Foo-Batch.ear" are as follows:
java:global/Foo-Batch/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerLocal
java:app/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerLocal
java:module/QuartzManagerBean!foo.services.interfaces.IQuartzManagerLocal
java:global/Foo-Batch/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote
java:app/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote
java:module/QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote
java:jboss/exported/Foo-Batch/Foo-Services/QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote
QuartzManagerBean
package foo.services.bean;
@Startup
@Singleton
@Remote(IQuartzManagerRemote.class)
@TransactionManagement(value=TransactionManagementType.BEAN)
@TransactionAttribute(value=TransactionAttributeType.NOT_SUPPORTED)
@WebService(name = "BatchQuartzManagerBean", targetNamespace = "urn:foo", serviceName = "BatchQuartzManagerBean")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED, use = SOAPBinding.Use.LITERAL)
public class QuartzManagerBean implements IQuartzManagerLocal, IQuartzManagerRemote{
...
public synchronized ReturnType fooMethod(
String serverName,
....
)
{
...
}
...
}
finally, the interface IQuartzManagerRemote
@Remote
@WebService
public interface IQuartzManagerRemote {
@WebMethod(operationName = "fooMethod")
public ReturnType fooMethod(
@WebParam(name="serverName") String serverName,
....
);
}
On the server B, I need to make a remote acces to this EJB. I tried several approaches, like this
env.put("endpoint.name","client-endpoint");
env.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
env.put("remote.connections", "default");
env.put("remote.connection.default.host","127.0.0.1");
env.put("remote.connection.default.port","4447");
env.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
env.put("jboss.naming.client.ejb.context", true);
context = new InitialContext(env);
or this
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL,"rhttp://localhost:8080/Foo-Services/BatchQuartzManagerBean/BatchQuartzManagerBean:4447");
// This is an important property to set if you want to do EJB invocations via the remote-naming project
jndiProps.put("jboss.naming.client.ejb.context", true);
// create a context passing these properties
Context context = new InitialContext(jndiProps);
or this
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL,"remote://localhost:4447");
jndiProps.put("jboss.naming.client.ejb.context", true);
// create a context passing these properties
InitialContext ctx = new InitialContext(jndiProps);
or this
Properties p = new Properties();
p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
p.put("remote.connections", "one");
p.put("remote.connection.one.port", "4447");
p.put("remote.connection.one.host", "localhost");
p.put("jboss.naming.client.ejb.context", true);
EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);
ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
EJBClientContext.setSelector(selector);
etc....
in the end, I need to perform a lookup and, again, I tried different ways.
QuartzManagerRemote quartzWSClient = (IQuartzManagerRemote) context.lookup("ejb:" + "Foo-Batch" + "/" + "Foo-Services" + "/" + "/" +"QuartzManagerBean" + "!" +IQuartzManagerRemote.class.getName());
or with java:
or java:exported/
probably all combinations..
The result is almost always the same. If I use the lookup started with java:
I get the
ERROR [stderr] (http-/127.0.0.1:8180-6) javax.naming.NameNotFoundException: Foo-Batch/Foo-Services//QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote -- service jboss.naming.context.java.jboss.exported.Foo-Batch.Foo-Services."QuartzManagerBean!foo.services.interfaces.IQuartzManagerRemote"
on the other hand, If I use the lookup started with ejb...
java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:Foo-Batch, moduleName:Foo-Services, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@4c42ff8
Note I can access this bean using SOAP-UI and the generated WSDL as webservice, so the service is up. However, my intention is to access using EJB.