WildFly - 来自远程客户端的 EJB 调用 - 操作失败,状态为 WAITING
WildFly - EJB invocations from a remote client - Operation failed with status WAITING
以下是我调用 ejb 的代码,但它等待连接并失败。我将端口更改为 4447,但没有成功。
private DataGridService lookupRemoteEJB() throws NamingException {
Context context = null;
try {
Properties clientProperties = new Properties();
clientProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
clientProperties.put("remote.connections", "default");
clientProperties.put("remote.connection.default.port", "4447");
clientProperties.put("remote.connection.default.host", "127.0.0.1");
clientProperties.put("remote.connection.default.username", "admin");
clientProperties.put("remote.connection.default.password", "password");
clientProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(clientProperties);
ContextSelector<EJBClientContext> contextSelector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(contextSelector);
Properties properties = new Properties();
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
context = new InitialContext(properties);
String jndiName = "ejb:poc_ear-1.0/poc_ejbs-1.0//DataGridServiceImpl!com.oms.ejbs.DataGridService";
System.out.println("____" + jndiName);
return (DataGridService) context.lookup(jndiName);
} finally {
if (context != null) {
context.close();
}
}
}
无状态会话 bean 的服务器控制台中的 JNDI。
11:00:53,220 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean name
d DataGridServiceImpl in deployment unit subdeployment "poc_ejbs-1.0.jar" of deployment "poc_ear-1.0.ear" are as follows:
java:global/poc_ear-1.0/poc_ejbs-1.0/DataGridServiceImpl!com.oms.ejbs.DataGridService
java:app/poc_ejbs-1.0/DataGridServiceImpl!com.oms.ejbs.DataGridService
java:module/DataGridServiceImpl!com.oms.ejbs.DataGridService
java:jboss/exported/poc_ear-1.0/poc_ejbs-1.0/DataGridServiceImpl!com.oms.ejbs.DataGridService
java:global/poc_ear-1.0/poc_ejbs-1.0/DataGridServiceImpl
java:app/poc_ejbs-1.0/DataGridServiceImpl
java:module/DataGridServiceImpl
11:00:53,284 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221007: Server is now live
11:00:53,285 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221001: HornetQ Server version 2.4.1.Final (Fast Hornet, 124) [73e4f957-b7a5-11
错误跟踪:
____ejb:poc_ear-1.0/poc_ejbs-1.0//DataGridServiceImpl!com.oms.ejbs.DataGridService
Feb 19, 2015 10:48:33 AM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 2.0.1.Final
Feb 19, 2015 10:48:34 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.2.Final
Feb 19, 2015 10:48:36 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.2.Final
Feb 19, 2015 10:48:38 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version (unknown)
Feb 19, 2015 10:48:44 AM org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector setupEJBReceivers
WARN: Could not register a EJB receiver for connection to 127.0.0.1:1099
java.lang.RuntimeException: Operation failed with status WAITING
at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:94)
at org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:77)
at org.jboss.ejb.client.remoting.RemotingConnectionManager.getConnection(RemotingConnectionManager.java:51)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:155)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:115)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:47)
at org.jboss.ejb.client.EJBClientContext.getCurrent(EJBClientContext.java:271)
at org.jboss.ejb.client.EJBClientContext.requireCurrent(EJBClientContext.java:281)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:176)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)
at com.sun.proxy.$Proxy0.getData(Unknown Source)
at com.oms.client.EJBInvoker.main(EJBInvoker.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
以下行解决了我的问题,端口必须更改为 8080
clientProperties.put("remote.connection.default.port", "8080");
同样的问题,http 端口没有帮助我。
我可以用远程端口来做。
我已添加:
<subsystem xmlns="urn:jboss:domain:remoting:2.0">
...
<connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>
</subsystem>
并添加端口:
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<socket-binding name="remoting" port="4447"/>
</socket-binding-group>
编辑:本地我只能连接远程 4447 和 webstart (jnlp) 只能使用 http 端口...
以下是我调用 ejb 的代码,但它等待连接并失败。我将端口更改为 4447,但没有成功。
private DataGridService lookupRemoteEJB() throws NamingException {
Context context = null;
try {
Properties clientProperties = new Properties();
clientProperties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
clientProperties.put("remote.connections", "default");
clientProperties.put("remote.connection.default.port", "4447");
clientProperties.put("remote.connection.default.host", "127.0.0.1");
clientProperties.put("remote.connection.default.username", "admin");
clientProperties.put("remote.connection.default.password", "password");
clientProperties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
EJBClientConfiguration ejbClientConfiguration = new PropertiesBasedEJBClientConfiguration(clientProperties);
ContextSelector<EJBClientContext> contextSelector = new ConfigBasedEJBClientContextSelector(ejbClientConfiguration);
EJBClientContext.setSelector(contextSelector);
Properties properties = new Properties();
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
context = new InitialContext(properties);
String jndiName = "ejb:poc_ear-1.0/poc_ejbs-1.0//DataGridServiceImpl!com.oms.ejbs.DataGridService";
System.out.println("____" + jndiName);
return (DataGridService) context.lookup(jndiName);
} finally {
if (context != null) {
context.close();
}
}
}
无状态会话 bean 的服务器控制台中的 JNDI。
11:00:53,220 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean name
d DataGridServiceImpl in deployment unit subdeployment "poc_ejbs-1.0.jar" of deployment "poc_ear-1.0.ear" are as follows:
java:global/poc_ear-1.0/poc_ejbs-1.0/DataGridServiceImpl!com.oms.ejbs.DataGridService
java:app/poc_ejbs-1.0/DataGridServiceImpl!com.oms.ejbs.DataGridService
java:module/DataGridServiceImpl!com.oms.ejbs.DataGridService
java:jboss/exported/poc_ear-1.0/poc_ejbs-1.0/DataGridServiceImpl!com.oms.ejbs.DataGridService
java:global/poc_ear-1.0/poc_ejbs-1.0/DataGridServiceImpl
java:app/poc_ejbs-1.0/DataGridServiceImpl
java:module/DataGridServiceImpl
11:00:53,284 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221007: Server is now live
11:00:53,285 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 56) HQ221001: HornetQ Server version 2.4.1.Final (Fast Hornet, 124) [73e4f957-b7a5-11
错误跟踪:
____ejb:poc_ear-1.0/poc_ejbs-1.0//DataGridServiceImpl!com.oms.ejbs.DataGridService
Feb 19, 2015 10:48:33 AM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 2.0.1.Final
Feb 19, 2015 10:48:34 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.2.Final
Feb 19, 2015 10:48:36 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.2.Final
Feb 19, 2015 10:48:38 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version (unknown)
Feb 19, 2015 10:48:44 AM org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector setupEJBReceivers
WARN: Could not register a EJB receiver for connection to 127.0.0.1:1099
java.lang.RuntimeException: Operation failed with status WAITING
at org.jboss.ejb.client.remoting.IoFutureHelper.get(IoFutureHelper.java:94)
at org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:77)
at org.jboss.ejb.client.remoting.RemotingConnectionManager.getConnection(RemotingConnectionManager.java:51)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:155)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:115)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:47)
at org.jboss.ejb.client.EJBClientContext.getCurrent(EJBClientContext.java:271)
at org.jboss.ejb.client.EJBClientContext.requireCurrent(EJBClientContext.java:281)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:176)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)
at com.sun.proxy.$Proxy0.getData(Unknown Source)
at com.oms.client.EJBInvoker.main(EJBInvoker.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
以下行解决了我的问题,端口必须更改为 8080
clientProperties.put("remote.connection.default.port", "8080");
同样的问题,http 端口没有帮助我。 我可以用远程端口来做。
我已添加:
<subsystem xmlns="urn:jboss:domain:remoting:2.0">
...
<connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/>
</subsystem>
并添加端口:
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<socket-binding name="remoting" port="4447"/>
</socket-binding-group>
编辑:本地我只能连接远程 4447 和 webstart (jnlp) 只能使用 http 端口...