【问题标题】:JBREM000200: Remote connection failed: java.io.IOException: An existing connection was forcibly closed by the remote hostJBREM000200:远程连接失败:java.io.IOException:现有连接被远程主机强行关闭
【发布时间】:2015-12-09 05:58:24
【问题描述】:

这是我的客户代码

package com.tutorialspoint.test;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.tutorialspoint.stateless.testRemote;

public class test 
{
    BufferedReader brConsoleReader = null;
    Properties props;
    static InitialContext ctx;
    {
        props = new Properties();
        try {
            props.load(new FileInputStream("jndi.properties"));
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        try {
            ctx = new InitialContext(props);            
        } catch (NamingException ex) {
            ex.printStackTrace();
        }
        brConsoleReader = 
        new BufferedReader(new InputStreamReader(System.in));
    }

public static void main(String[] args)
{
    test _test = new test();
    try {
        testRemote libraryBean =(testRemote)ctx.lookup("java:global/TestEjb/testBean!     
           com.tutorialspoint.stateless.testRemote");
    } catch (NamingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }    
}
}

这是部署在服务器上

package com.tutorialspoint.stateless;
import javax.ejb.Stateless;
@Stateless
public class testBean implements testRemote 
{
  public void hello()
  {
    System.out.println("hello");
  }
}

 package com.tutorialspoint.stateless;
 import javax.ejb.Remote;

 @Remote
 public interface testRemote 
 {
    void hello();
 }

我在服务器端遇到异常:

19:09:12,676 错误 [org.jboss.remoting.remote.connection](远程处理“cognam-
pc-26" read-1) JBREM000200:远程连接失败: java.io.IOException: 一个现有的连接被
强行关闭 远程主机

我在客户端遇到异常:-

javax.naming.CommunicationException:无法获得连接 到这些网址中的任何一个: localhost:4447 并且发现失败并出现错误: javax.naming.CommunicationException:接收超时[根异常 是 java.net.SocketTimeoutException: 接收超时] [根异常 是 javax.naming.CommunicationException:无法从中检索存根 服务器 localhost:4447 [根异常是 java.io.StreamCorruptedException:
无效的流标头:0000000F]]

org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414) 在 org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594) 在 org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587) 在 javax.naming.InitialContext.lookup(InitialContext.java:392) 在 com.tutorialspoint.test.test.main(test.java:37)

【问题讨论】:

  • 它只被调用一次
  • 那我猜你的剪切和粘贴不正确或者我看错了,我会删除我的cmets。
  • 这可能是您的服务器实际上不允许连接到 4447。检查您是否可以 telnet 到该端口或使用 netstat -an 查询。

标签: java eclipse ejb jboss7.x


【解决方案1】:

这可能是您的服务器实际上不允许连接到 4447。检查您是否可以 telnet 到该端口或使用 netstat -an 来查询。

还要确保没有防火墙阻止对端口的访问。

【讨论】:

  • 感谢回复,我通过更改 jndi.proerties 来做到这一点,在更改 jndi.properties 后使用 jnp 上下文之前:- props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.remote.client.InitialContextFactory"); props.put(Context.PROVIDER_URL, "remote://localhost:4447"); props.put("jboss.naming.client.ejb.context", true); props.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
  • 我没有关注,这是否意味着您的问题已解决?
  • 谁能告诉我如何在调用 ejb 时使用凭据配置 ejb 安全性
【解决方案2】:

如果正在运行,请尝试关闭任何 http 流量捕获工具(例如 Fiddler)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-12
    相关资源
    最近更新 更多