11 Replies Latest reply on Jan 24, 2005 3:26 PM by rverlind

    Connection time out

    rverlind

      I have problems getting an RMI connection to a JBoss server over the public internet. Using exactly the same code and server configuration it works flawlessly from within the same LAN (public IP's 134.184.xxx.xxx). The exception thrown is displayed at the bottom of this message.

      I know for sure the server isn't firewalled so that can't be the reason.

      Below you can find the code for getting the EJBHome object and initialising the context and the thrown Exception.

      Any pointers to a possible solution are very welcome.

      thx,
      Ruben


      Initial Context code (In Eclipse plugin) :

      private static final String IntialContextNamingFactory = "org.jnp.interfaces.NamingContextFactory";
       private static final String NamingProviderURL = "134.184.xxx.xxx";
      
       /**
       * Returns the initial jndi context.
       * The parameters are hard coded into this function for the moment and some
       * ClassLoader tricks are necessary to intialise the JNDI environment.
       *
       * @return Context
       * @throws NamingException
       */
       static public Context getInitialContext()
       throws NamingException {
       InitialContext context;
      
       // Save the current ClassLoader for reloading it after the JNDI
       // environment is intialised.
       ClassLoader tmp = Thread.currentThread().getContextClassLoader();
      
       // get the plugin ClassLoader to initialise the JNDI environment
       Thread.currentThread().setContextClassLoader(pluginType.getClassLoader());
      
       // The context properties
       Properties p = new Properties();
       p.setProperty("java.naming.factory.initial", IntialContextNamingFactory);
       p.setProperty("java.naming.provider.url", NamingProviderURL);
      
       // Initialise the JNDI environment
       context = new InitialContext(p);
      
       // Reinstate the system ClassLoader
       Thread.currentThread().setContextClassLoader(tmp);
      
       return context;
       }
      


      Get EJBHome :
       /**
       * Retrieves the Home interface of the EJB and puts the HomeHandle in the cache
       *
       * @param jndiName : the service name, e.g. OntoBaseFacadeEJBHome
       * @param type : class of the HomeRemote interface, e.g.OntoBaseFacadeEJBHomeRemote.class
       * @throws ServiceLocatorException
       */
       private void getJndiService(String jndiName, Class type)
       throws ServiceLocatorException{
       // Access to the shared Context as well as the additions to the
       // cache must be synchronised.
       synchronized(this) {
       try {
       // Lookup the JNDI name and retrieve the EJBHome object
       Object rRef = context.lookup(jndiName);
       EJBHome home = (EJBHome)PortableRemoteObject.narrow(rRef, type);
      
       // Put the EJBHome object in the cache
       cache.put(jndiName, home);
      
       // Code when using HomeHandles in the cache instead of EJBHome objects
       // Put the HomeHandle of the EJBHome object in the cache
       //cache.put(jndiName, home.getHomeHandle());
      
       } catch(NamingException ne) {
       System.out.println("Unable to find JNDI service. " + ne.toString());
       throw new ServiceLocatorException("Unable to find JNDI service",ne);
       }
       // This Exception is only thrown when using HomeHandles in the cache instead of
       // EJBHome objects
       /*catch(RemoteException re){
       System.out.println("Remote Exception in ServiceLocatorEJB. " + re.toString());
       throw new ServiceLocatorException("Remote Exception in ServiceLocatorEJB",re);
       }*/
       }
       }
      


      Exception :
      java.rmi.ConnectException: Connection refused to host: 134.184.xxx.xxx;
      nested exception is:
       java.net.ConnectException: Connection timed out: connect
       at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
       at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
       at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
       at sun.rmi.server.UnicastRef.invoke(Unknown Source)
       at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
       at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy java:135)
       at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
       at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
       at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
       at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
       at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
       at $Proxy0.create(Unknown Source)
       at vub.starlab.ds.bdelegate.ejb.OntoBaseDelegateEJB.init(OntoBaseDelegateEJB.java:68)
       at vub.starlab.ds.bdelegate.ejb.OntoBaseDelegateEJB.<init>(OntoBaseDelegateEJB.java:53)
       at vub.starlab.ds.bdelegate.BDFactory.getOntoBaseDelegate(BDFactory.java:44)
       at vub.starlab.ds.ontobase.controller.OntoBaseSubsetCacheAdapter.init(OntoBaseSubsetCacheAdapter.java:52)
       at vub.starlab.ds.ontobase.controller.OntoBaseSubsetCacheAdapter.<init>(OntoBaseSubsetCacheAdapter.java:41)
       at vub.starlab.ds.ontobase.controller.OntoBaseController.init(OntoBaseController.java:62)
       at vub.starlab.ds.ontobase.controller.OntoBaseController.<init>(OntoBaseController.java:57)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
      Source)
       at java.lang.reflect.Constructor.newInstance(Unknown Source)
       at java.lang.Class.newInstance0(Unknown Source)
       at java.lang.Class.newInstance(Unknown Source)
       at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:153)
       at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:933)
       at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:417)
       at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:293)
       at org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLocalClass(EclipseClassLoader.java:110)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:371)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.requireClass(BundleLoader.java:336)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findRequiredClass(BundleLoader.java:914)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:399)
       at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:93)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at java.lang.ClassLoader.loadClassInternal(Unknown Source)
       at java.lang.ClassLoader.defineClass0(Native Method)
       at java.lang.ClassLoader.defineClass(Unknown Source)
       at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:298)
       at org.eclipse.core.runtime.adaptor.EclipseClassLoader.defineClass(EclipseClassLoader.java:223)
       at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader.findClassImpl(DefaultClassLoader.java:281)
       at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader.findClass(DefaultClassLoader.java:172)
       at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.findLocalClass(AbstractClassLoader.java:220)
       at org.eclipse.core.runtime.adaptor.EclipseClassLoader.basicFindLocalClass(EclipseClassLoader.java:135)
       at org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLocalClass(EclipseClassLoader.java:73)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:371)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:402)
       at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:93)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.loadClass(BundleLoader.java:307)
       at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:332)
       at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:151)
       at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:933)
       at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:417)
       at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:293)
       at org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLocalClass(EclipseClassLoader.java:110)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:371)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.requireClass(BundleLoader.java:336)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findRequiredClass(BundleLoader.java:914)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:399)
       at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:93)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at java.lang.ClassLoader.loadClassInternal(Unknown Source)
       at java.lang.ClassLoader.defineClass0(Native Method)
       at java.lang.ClassLoader.defineClass(Unknown Source)
       at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:298)
       at org.eclipse.core.runtime.adaptor.EclipseClassLoader.defineClass(EclipseClassLoader.java:223)
       at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader.findClassImpl(DefaultClassLoader.java:281)
       at org.eclipse.osgi.framework.internal.defaultadaptor.DefaultClassLoader.findClass(DefaultClassLoader.java:172)
       at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.findLocalClass(AbstractClassLoader.java:220)
       at org.eclipse.core.runtime.adaptor.EclipseClassLoader.basicFindLocalClass(EclipseClassLoader.java:135)
       at org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLocalClass(EclipseClassLoader.java:59)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findLocalClass(BundleLoader.java:371)
       at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:402)
       at org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader.loadClass(AbstractClassLoader.java:93)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at java.lang.ClassLoader.loadClassInternal(Unknown Source)
       at vub.starlab.ds.conceptbase.termdefinitionview.views.TermDefinitionView.createPartControl(TermDefinitionView.java:85)
       at org.eclipse.ui.internal.PartPane$2.run(PartPane.java:148)
       at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
       at org.eclipse.core.runtime.Platform.run(Platform.java:747)
       at org.eclipse.ui.internal.PartPane.doCreateChildControl(PartPane.java:144)
       at org.eclipse.ui.internal.ViewPane.doCreateChildControl(ViewPane.java:135)
       at org.eclipse.ui.internal.PartPane.createChildControl(PartPane.java:349)
       at org.eclipse.ui.internal.ViewFactory$1.run(ViewFactory.java:398)
       at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
       at org.eclipse.core.runtime.Platform.run(Platform.java:747)
       at org.eclipse.ui.internal.ViewFactory.busyRestoreView(ViewFactory.java:287)
       at org.eclipse.ui.internal.ViewFactory$2.run(ViewFactory.java:582)
       at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
       at org.eclipse.ui.internal.ViewFactory.restoreView(ViewFactory.java:579)
       at org.eclipse.ui.internal.ViewFactory$ViewReference.getPart(ViewFactory.java:106)
       at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:329)
       at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:607)
       at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:126)
       at org.eclipse.ui.internal.presentations.newapi.PresentablePartFolder.select(PresentablePartFolder.java:266)
       at org.eclipse.ui.internal.presentations.newapi.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
       at org.eclipse.ui.internal.presentations.newapi.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:381)
       at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1034)
       at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1008)
       at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1183)
       at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:520)
       at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:472)
       at org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:477)
       at org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:230)
       at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:779)
       at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2028)
       at org.eclipse.ui.internal.WorkbenchWindow$4.run(WorkbenchWindow.java:2158)
       at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
       at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:2144)
       at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage(WorkbenchWindow.java:565)
       at org.eclipse.ui.internal.Workbench.busyOpenWorkbenchWindow(Workbench.java:579)
       at org.eclipse.ui.internal.Workbench.openFirstTimeWindow(Workbench.java:1170)
       at org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow(WorkbenchConfigurer.java:178)
       at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:665)
       at org.eclipse.ui.internal.Workbench.init(Workbench.java:886)
       at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1516)
       at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:285)
       at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144)
       at vub.starlab.ds.rcp.RcpApplication.run(RcpApplication.java:26)
       at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:220)
       at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
       at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
       at org.eclipse.core.launcher.Main.run(Main.java:710)
       at org.eclipse.core.launcher.Main.main(Main.java:694)
      Caused by: java.net.ConnectException: Connection timed out: 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.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 sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
       at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
       ... 131 more


        • 1. Re: Connection time out
          frito

          there is probably a firewall in the way. Open the needed ports or don't use RMI. The jndi lookup can be done e.g. over http and you can configure the invocation layer used for beans.

          • 2. Re: Connection time out
            rverlind

            No firewall in the way.

            But I will probably try to do it over http anyway.

            • 3. Re: Connection time out
              frito

              I bet windows client (XP) with the built in internet security stuff or some other client firewall software...

              • 4. Re: Connection time out
                rverlind

                I've tried it with windows XP before SP2 (no firewall installed then) and had the same problem. But I will look into the SP2 firewall to be 100% sure.

                • 5. Re: Connection time out
                  frito

                  Even SP1 has the internet security (afaik default turned on). SP2 just "improved" it... *G*
                  To be sure this isn't the problem, just turn off the whole service. And beware of routers with active firewalls...
                  I'll still bet you on this ;-)

                  • 6. Re: Connection time out
                    venkateshbalaji

                    Hi ruben,

                    I am facing the same problem, My application works fine with LAN, if i tried with public ip address, upto look-up part was completed, but cannot create home, getting a exception unable to connect....if u have any solution kindly update me, its really very urgent.

                    • 7. Re: Connection time out
                      rverlind

                      Tried it with firewall disabled, no router in betweetn, etc. but with the same result.

                      I will try to use the JNDI & RMI over http. Needed to do that anyway, since people who are going to use the client application will be behind a firewall anyway.

                      Ruben

                      • 8. Re: Connection time out
                        rverlind

                        The JNDI over http works OK now. Still need to test the RMI/http.

                        It seems it is wise to use the http transport layer for JNDI & RMI anyway when the transfer is over the public internet. Less problems with corporate firewalls, etc.

                        • 9. Re: Connection time out
                          frito

                          This for sure...

                          • 10. Re: Connection time out
                            frito

                            ... or HTTP for lookups and RMI /SSL for invocation...

                            • 11. Re: Connection time out
                              rverlind

                              Finally got it working now. Took so long due to my own stupidity.

                              I just followed the guidelines in the JBoss Administration & Development Book.
                              Still got failures testing from an Eclipse RCP application and couldn't the problem. After a day or 2 ran my ant test scripts which don't use Eclipse and it ran flawlessly. Seemed the RMI over HTTP also needed the use of another Classloader for the home;.create() to work, while the RMI/IIOP didn't neeed this.

                              So, if you need to use RMI/HTTP just (almost literally) do what the JBoss Adiministration and Development book tells you in the sections in JNDI over HTTP and RMI over HTTP.

                              Ruben