gpt4 book ai didi

java - JBREM000200 : Remote connection failed: java. io.IOException:现有连接被远程主机强制关闭

转载 作者:太空宇宙 更新时间:2023-11-04 13:08:45 24 4
gpt4 key购买 nike

这是我的客户端代码

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 ERROR [org.jboss.remoting.remote.connection] (Remoting "cognam-
pc-26" read-1) JBREM000200: Remote connection failed:java.io.IOException: An existing connection was forcibly closed by the
remote host

我在客户端遇到异常:-

javax.naming.CommunicationException: Could not obtain connectionto any of these urls: localhost:4447 and discovery failed with error:javax.naming.CommunicationException: Receive timed out [Root exceptionis java.net.SocketTimeoutException: Receive timed out] [Root exceptionis javax.naming.CommunicationException: Failed to retrieve stub fromserver localhost:4447 [Root exception is java.io.StreamCorruptedException:
invalid stream header: 0000000F]]

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

最佳答案

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

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

关于java - JBREM000200 : Remote connection failed: java. io.IOException:现有连接被远程主机强制关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34171725/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com