NameNotFoundException performing JNDI lookup for remote EJB in JBoss production (works locally)

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 
+6
source share
1 answer

This may be a network connectivity issue. I would check if the server allows data exchange on remote ports. Try the telnet server if it is configured to accept these requests:

 telnet <server> <port> 

If you use the default ports, I think it should be 4447. If this connection does not work, answer the following: 1. There is no firewall that can block this message. 2. Do you use the correct port configured by your production server.

There may be other reasons for the failure, but that will be the starting point.

+1
source

Source: https://habr.com/ru/post/989832/


All Articles