title: How should I initialize the Context to accessing remote GlassFish server?
body: <p>I am using a GlassFish-4.0 in my subnet (192.168.1.115:3700). I have already deployed an enterprise application including an EJB, in which I defined some business methods. Now I would like to remotely access the EJB from my Java application client.</p>
  
  <p>I am trying something like this:</p>
  
  <pre><code>System.setProperty("org.omg.CORBA.ORBInitialHost", "192.168.1.115");
  System.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
  InitialContext ctx = new InitialContext();
  GreetingService bean = (GreetingService) ctx.lookup(GreetingService.JNDI_NAME);
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 192.168.1.115; port: 3700  vmcid: OMG  minor code: 1  completed: No
      at com.sun.proxy.$Proxy17.connectFailure(Unknown Source)
      at com.sun.corba.ee.impl.transport.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:253)
      at com.sun.corba.ee.impl.transport.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:276)
      at com.sun.corba.ee.impl.transport.ContactInfoImpl.createConnection(ContactInfoImpl.java:129)
      at com.sun.corba.ee.impl.protocol.ClientRequestDispatcherImpl.beginRequest(ClientRequestDispatcherImpl.java:243)
      at com.sun.corba.ee.impl.protocol.ClientDelegateImpl.request(ClientDelegateImpl.java:227)
      at com.sun.corba.ee.impl.protocol.ClientDelegateImpl.is_a(ClientDelegateImpl.java:392)
      at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:130)
      at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
      at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNameService(SerialContext.java:1205)
      at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:393)
      at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:329)
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:477)
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
      at javax.naming.InitialContext.lookup(InitialContext.java:411)
      at hu.igergo.java.dummy.client.Main.main(Main.java:28)
  Caused by: java.lang.RuntimeException: java.net.ConnectException: Kapcsolat elutasítva
      at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:344)
      at com.sun.corba.ee.impl.transport.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:250)
      ... 14 more
  Caused by: java.net.ConnectException: Kapcsolat elutasítva
      at sun.nio.ch.Net.connect0(Native Method)
      at sun.nio.ch.Net.connect(Net.java:465)
      at sun.nio.ch.Net.connect(Net.java:457)
      at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:670)
      at com.sun.corba.ee.impl.misc.ORBUtility.openSocketChannel(ORBUtility.java:110)
      at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:329)
      ... 15 more
  Exception in thread main javax.naming.NamingException: Lookup failed for 'greeting' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 192.168.1.115; port: 3700  vmcid: OMG  minor code: 1  completed: No]]
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
      at javax.naming.InitialContext.lookup(InitialContext.java:411)
      at hu.igergo.java.dummy.client.Main.main(Main.java:28)
  Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 192.168.1.115; port: 3700  vmcid: OMG  minor code: 1  completed: No]
      at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:334)
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:477)
      ... 3 more
  Caused by: org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 192.168.1.115; port: 3700  vmcid: OMG  minor code: 1  completed: No
      at com.sun.proxy.$Proxy17.connectFailure(Unknown Source)
      at com.sun.corba.ee.impl.transport.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:253)
      at com.sun.corba.ee.impl.transport.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:276)
      at com.sun.corba.ee.impl.transport.ContactInfoImpl.createConnection(ContactInfoImpl.java:129)
      at com.sun.corba.ee.impl.protocol.ClientRequestDispatcherImpl.beginRequest(ClientRequestDispatcherImpl.java:243)
      at com.sun.corba.ee.impl.protocol.ClientDelegateImpl.request(ClientDelegateImpl.java:227)
      at com.sun.corba.ee.impl.protocol.ClientDelegateImpl.is_a(ClientDelegateImpl.java:392)
      at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl.java:130)
      at org.omg.CosNaming.NamingContextHelper.narrow(NamingContextHelper.java:69)
      at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNameService(SerialContext.java:1205)
      at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:393)
      at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:329)
      ... 4 more
  Caused by: java.lang.RuntimeException: java.net.ConnectException: Kapcsolat elutasítva
      at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:344)
      at com.sun.corba.ee.impl.transport.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:250)
      ... 14 more
  Caused by: java.net.ConnectException: Kapcsolat elutasítva
      at sun.nio.ch.Net.connect0(Native Method)
      at sun.nio.ch.Net.connect(Net.java:465)
      at sun.nio.ch.Net.connect(Net.java:457)
      at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:670)
      at com.sun.corba.ee.impl.misc.ORBUtility.openSocketChannel(ORBUtility.java:110)
      at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:329)
      ... 15 more
  </code></pre>
  
  <p>I only configured ORB / IIOP (127.0.0.1). I didn't change anything on the default JNDI settings. <a href="http://i.stack.imgur.com/pVmt6.png" rel="nofollow">Screenshot</a></p>
  
  <p>What am I doing wrong?</p>