我正在尝试调用属于EJB的远程方法。
我使用以下命令启动了服务器:
$ bin/standalone.sh --server-config=standalone-ha.xml -Djboss.node.name=node1
根据我的理解,此服务器的默认套接字绑定端口为9999。 部署的ejb远程和家庭界面可以在这里看到(抱歉链接 - 我没有适当的评级在堆栈溢出时发布图像):
http://www.rakkatak.com/so/stackoverflow_question_ejb_img1.png
这是EJB:
package org.jboss.as.quickstarts.cluster.hasingleton.service.ejb;
import javax.ejb.Stateless;
import org.jboss.as.server.CurrentServiceContainer;
import org.jboss.logging.Logger;
import org.jboss.msc.service.ServiceController;
@Stateless
public class ServiceAccessBean implements ServiceAccess {
private static final Logger LOGGER = Logger.getLogger(ServiceAccessBean.class);
public String getNodeNameOfTimerService() {
LOGGER.info("Method getNodeNameOfTimerService() is invoked");
return "test";
}
}
界面:
package org.jboss.as.quickstarts.cluster.hasingleton.service.ejb;
import javax.ejb.Remote;
@Remote
public interface ServiceAccess {
String getNodeNameOfTimerService();
}
在我的客户端jar中,我已经在类路径中放置了jboss-ejb-client.properties,它看起来像这样:
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=node1
remote.connection.node1.host=localhost
remote.connection.node1.port = 9999
remote.connection.node1.connect.timeout = 500
remote.connection.node1.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
以下是调用ejb方法的代码:
final Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
final Context context = new InitialContext(jndiProperties);
String lookupName = "ejb:/jboss-cluster-ha-singleton-service/ServiceAccessBean!" + ServiceAccess.class.getName();
System.out.println("Lookup Bean name is " + lookupName);
ServiceAccess accessBean = (ServiceAccess) context.lookup(lookupName);
accessBean.getNodeNameOfTimerService();
不幸的是,当调用此代码时,我收到以下异常,该异常在调用accessBean.getNodeNameOfTimerService()时发生。
java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:, moduleName:jboss-as-cluster-ha-singleton-service, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@47dc7ae2
如果上述内容不正确,请告知我们。谢谢!