2016-07-13 50 views
1

我正在使用以下代码在java applet中使用远程连接。远程连接在蜻蜓一段时间后掉线

Hashtable jndiProps = new Hashtable<Object,Object>(); 
    jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); 
    jndiProps.put(Context.PROVIDER_URL, "http-remoting://" + myhost + ":" + "8080"); 
    jndiProps.put("jboss.naming.client.ejb.context", true); 
    jndiProps.put("org.jboss.ejb.client.scoped.context", true);; 
    //jndiProps.put(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming"); 
    jndiProps.put("endpoint.name", "client-endpoint"); 
    jndiProps.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", false); 
    jndiProps.put("remote.connections", "default"); 
    jndiProps.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", false); 
    jndiProps.put("remote.connection.default.host", myhost); 
    jndiProps.put("remote.connection.default.port", "8080"); 
    jndiProps.put(Context.SECURITY_PRINCIPAL, "demouser"); 
    jndiProps.put(Context.SECURITY_CREDENTIALS, "demouser123"); 
    InitialContext ctx = null; 
    try { 
     ctx = new InitialContext(jndiProps); 
    } catch(NamingException nex) { 
     nex.printStackTrace(); 
    } catch(Exception ex) { 
     ex.printStackTrace(); 
    } 
    RemoteInterface remote = (RemoteInterface)ctx.lookup(ejbUrl); 

这里SECURITY_PRINCIPAL是使用add-user.sh脚本创建的。该applet加载,一切正常。但有时在Java控制台后,会出现一条消息说

2016年7月13日下午3时04分21秒org.jboss.ejb.client.remoting.ChannelAssociation $ ResponseReceiver handleEnd 信息:EJBCLIENT000016:通道通道ID 98a848d6 (出站)远程连接22d8b2a8到cms8sf.cdotd.ernet.in/192.168.5.240:8080不能再处理消息。

然后,每当我尝试访问抛出的任何远程bean异常的方法。

java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:app, moduleName:app-ejb, distinctName:] combination for invocation context [email protected] 
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:774) 

我很不确定为什么会发生这种情况。有人可以帮帮我吗。预先感谢。 我使用java 1.8和wildfly 9.0.2。

回答

0

也许,这个选项会帮助你

remote.connection.default.connect.options.org.jboss.remoting3.RemotingOptions.HEARTBEAT_INTERVAL = 5000

它是某种平