java - 远程 EJB 接口(interface)无法通过 Internet 工作

标签 java ejb-3.0 remoting amazon-web-services

我有一个 EJB 容器,部署在 Amazon AWS Fedora 8 虚拟机上的 JBoss 5.1 上。我有另一个应用程序,我想通过 Internet 远程访问此 EJB 容器。但我收到以下异常

javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: xxx.xxx.xx.x; nested exception is: java.net.ConnectException: Connection timed out]

Caused by: java.rmi.ConnectException: Connection refused to host: xxx.xxx.xx.x; nested exception is: java.net.ConnectException: Connection timed out

Caused by: java.net.ConnectException: Connection timed out

这里xxx.xxx.xx.x是运行EJB的机器的内部IP。

这是我用来访问它的代码

Properties props = new Properties(); 
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,org.jboss.security.jndi.JndiLoginInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "<external-ip>:1099");
props.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
props.put("java.naming.provider.url", "jnp://<external-ip>:1099");
InitialContext ic = new InitialContext(props);
ic.lookup("EJBName");

我还编辑了 /etc/hosts 文件,例如

127.0.0.1  localhost.localdomain localhost
xxx.xxx.xx.x  hostname  alias

并启动 JBoss

-Djboss.bind.address=0.0.0.0 -Djava.rmi.server.hostname=xxx.xxx.xx.x -Dremoting.bind_by_host=false

我想我已经完成了所有必要的配置和正确的代码,但似乎不起作用。请帮我解决这个问题,它已经困扰我一个多星期了。出于安全考虑,我们很抱歉隐藏了实际的 IP。

最佳答案

连接超时 这可能是防火墙问题。验证端口是否打开:http://www.canyouseeme.org/

您还可以尝试设置属性:“org.omg.CORBA.ORBInitialHost”和“org.omg.CORBA.ORBInitialPort”。

关于java - 远程 EJB 接口(interface)无法通过 Internet 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4706411/

相关文章:

java - 从独立应用程序调用 glassfish ejb

java - EJB 自动计时器、锁定、超时和长时间运行的方法

powershell - net use */delete/y 不能解决错误 "New-PSDrive : Multiple connections to a server ...."

java - 即使完成 Activity 后也无法停止 MusicPlayer。

java - 设置 Selenium 服务器

java - 无法将 ViaPost 发送到 Axis2 1.6 中的 url

java - 在 Maven 多模块项目的各个模块的测试之间保留 h2 数据库

ejb-3.0 - 如何使用 Arquillian Weld EE Embedded 测试 EJB 方法调用

java - 在不同远程对象之间拆分远程 EJB 功能

.net - 跨 DMZ 的代理调用