Bom dia,
Tenho uma aplicação em EJB com JBoss e um cliente desktop Swing. Usando no Eclipse funciona perfeitamente, mas quando coloco o cliente pra rodar em outra máquina ele não consegue achar o EJB.
//Usado para buscar um EJB
public static Object getBean(String jndiName) throws NamingException{
Properties prop = new Properties();
prop.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
prop.put(InitialContext.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
prop.put(InitialContext.PROVIDER_URL, "jnp://ctahq1-1399:1099");
InitialContext ctx = new InitialContext(prop);
return ctx.lookup(jndiName);
}
public static void main(String[] args){
UsuarioBO usuarioBO;
try {
usuarioBO = (UsuarioBO)ServiceLocator.getBean("UsuarioBean/remote");
} catch (NamingException e) {
throw new RuntimeException(e);
}
}
Exception in thread "main" java.lang.RuntimeException: javax.naming.CommunicationException: Could not obtain connection to any of these urls: ctahq1-1399:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server ctahq1-1399:1099 [Root exception is javax.naming.ServiceUnavailableException:
Failed to connect to server ctahq1-1399:1099 [Root exception is java.net.Connect
Exception: Connection refused: connect]]]
at Main.initAppNoLogin(Main.java:43)
at Main.main(Main.java:60)
Caused by: javax.naming.CommunicationException: Could not obtain connection to any of these urls: ctahq1-1399:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server ctahq1-1399:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server ctahq1-1399:1099
[Root exception is java.net.ConnectException: Connection refused: connect]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(Unknown Source)
at br.com.gvt.util.ServiceLocator.getBean(ServiceLocator.java:22)
at Main.initAppNoLogin(Main.java:41)
... 1 more
Caused by: javax.naming.CommunicationException: Failed to connect to server ctahq1-1399:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed
to connect to server ctahq1-1399:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
... 6 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server ctahq1-1399:1099 [Root exception is java.net.ConnectException: Connection refused: connect] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:248)
... 7 more
Caused by: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:244)
... 7 more
O que pode ser? Há algum tipo de configuração no JBoss para ele aceitar conexões de outras máquinas?
Obrigado!
