Aus dem folgenden Code versuche ich auf EJB auf einem Remote-Computer zuzugreifen.Wie setze ich JNDI Lookup Timeout auf Glassfish
Der Code läuft auf Glassfish 4.1. in einer Webanwendung.
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost","X.X.X.X");
props.setProperty("org.omg.CORBA.ORBInitialPort","3700");
//timeouts
props.setProperty("sun.rmi.transport.connectionTimeout","5000");
props.setProperty("sun.rmi.transport.tcp.handshakeTimeout","5000");
props.setProperty("sun.rmi.transport.tcp.responseTimeout","5000");
props.setProperty("sun.rmi.transport.tcp.readTimeout","5000");
props.setProperty("com.sun.corba.ee.transport.ORBWaitForResponseTimeout","5000");
props.setProperty("com.sun.corba.ee.transport.ORBTCPConnectTimeouts", "100:500:100:500");
props.setProperty("com.sun.corba.ee.transport.ORBTCPTimeouts", "500:2000:50:1000");
System.setProperty("com.sun.corba.ee.transport.ORBWaitForResponseTimeout","5000");
System.setProperty("com.sun.corba.ee.transport.ORBTCPConnectTimeouts","100:500:100:500");
System.setProperty("com.sun.corba.ee.transport.ORBTCPTimeouts","500:2000:50:1000");
System.setProperty("sun.rmi.transport.connectionTimeout","5000");
System.setProperty("sun.rmi.transport.tcp.handshakeTimeout","5000");
System.setProperty("sun.rmi.transport.tcp.responseTimeout","5000");
System.setProperty("sun.rmi.transport.tcp.readTimeout","5000");
//timeout
InitialContext ctx = new InitialContext(props);
MyRemoteInterface bean = (MyRemoteInterface)
ctx.lookup("ejbname#EjbName");
Wenn die Suche erfolgreich ist - alles funktioniert einwandfrei.
Das Problem ist jedoch, dass der Code hängt , wenn der Remote-Computer nicht verfügbar ist. Es unterscheidet sich auf Grund, über 1 min 20 seconds
wenn die ip nicht existent ist und über 10 minutes
, wenn die Remote-Rechner hinter einer Firewall ist, bis sie aufblicken Scheitern Ausnahme auslöst:
Severe: org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure:
...
...
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:101)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:622)
at com.sun.corba.ee.impl.misc.ORBUtility.openSocketChannel(ORBUtility.java:110)
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:329)
Und hier ist eine andere Ursache:
Caused by: java.net.ConnectException: Connection timed out: connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:454)
at sun.nio.ch.Net.connect(Net.java:446)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:648)
at com.sun.corba.ee.impl.misc.ORBUtility.openSocketChannel(ORBUtility.java:110)
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:329)
Ich möchte nicht so lange warten, um herauszufinden, dass die Suche fehlgeschlagen ist. Alle oben genannten Timeouts haben nicht geholfen. Wie kann ich ein Lookup-Timeout festlegen oder gibt es eine andere Problemumgehung?
Danke.
Meinst du ** JNDI ** Lookup Timeout? Wenn ja, sind Titel und Tags falsch. – EJP
@EJP ja JNDI - danke - gefixt. – Plirkee