An application (e.g. app.EAR) is deployed to JBoss on my own machine and works fine. When I deploy it to a remote JBoss, it deploys, but when I try to access functionality requiring a JNDI lookup for a remote EJB, I get a NameNotFoundException. Thus, it seems that he could not find the requested service. How so? If it works locally?
The dependency on the remote EJB interface is located in the lib folder inside the EAR and, of course, annotated using @Remote. JBoss is exactly the same as for production (I copied the entire JBoss from production to my machine to check if there was any configuration).
My search code is as follows:
private Object lookup(String resourceName, String loginData) { if (isPropagateUserCredentials() && (loginData == null || loginData.trim().equals(""))) { throw new MyInfraConfigException("somemessage"); } Properties envProperties = new Properties(); envProperties.putAll(this.jndiProperties); if (loginData != null && !loginData.equals("")) { envProperties.put(Context.SECURITY_PRINCIPAL, loginData); envProperties.remove(Context.SECURITY_CREDENTIALS); } Context context = null; try { context = new InitialContext(envProperties); return context.lookup(resourceName); } catch (NameNotFoundException e){ String message = "Resource "+resourceName+" not found."; LoggerFactory.getInstance(this.getClass().getName()).error(message, e); throw new com.mypackage.NameNotFoundException(message, e); } catch (NamingException e) { String message = "Failed to find resource with JNDI: "+e.getMessage(); LoggerFactory.getInstance(this.getClass().getName()).error(message, e); throw new com.mypackage.NamingException(message, e); } finally{ if(context!=null){ try { context.close(); } catch (NamingException e) { e.printStackTrace(); } } } }
The name of the resource is ExternalResource .
The following is a stacktrace table:
29/06/2015 10:30:43 oracle.j2ee.clustering.ClusteringMessages warningInOpmnGetServers AVISO: Error in obtaining server list from OPMN on host XX.XXX.XXX.XXX:XXXX. Please verify that OPMN is running. javax.naming.NameNotFoundException: ExternalResource not found at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:60) at javax.naming.InitialContext.lookup(InitialContext.java:392) at br.teste.TestaJNDI.main(TestaJNDI.java:33)
Any clues?
UPDATE Created an external simple java application to try to connect to the server and understand the cause of the problem. Actually the problem is that I get the connection timeout:
javax.naming.CommunicationException: Connection timed out [Root exception is java.net.ConnectException: Connection timed out] at com.evermind.server.rmi.RMIClient.lookup(RMIClient.java:311) at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:59) at javax.naming.InitialContext.lookup(Unknown Source) at br.teste.TestaJNDI.listaUFs(TestaJNDI.java:55) at br.teste.TestaJNDI.main(TestaJNDI.java:37) Caused by: java.net.ConnectException: Connection timed out 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 com.evermind.server.rmi.RMIClientConnection.createSocket(RMIClientConnection.java:802) at oracle.oc4j.rmi.ClientSocketRmiTransport.createNetworkConnection(ClientSocketRmiTransport.java:59) at oracle.oc4j.rmi.ClientRmiTransport.connectToServer(ClientRmiTransport.java:75) at oracle.oc4j.rmi.ClientSocketRmiTransport.connectToServer(ClientSocketRmiTransport.java:69) at com.evermind.server.rmi.RMIClientConnection.connect(RMIClientConnection.java:765) at com.evermind.server.rmi.RMIClientConnection.sendLookupRequest(RMIClientConnection.java:247) at com.evermind.server.rmi.RMIClientConnection.lookup(RMIClientConnection.java:231) at com.evermind.server.rmi.RMIClient.lookup(RMIClient.java:302) ... 4 more
source share