10 Replies Latest reply on Jan 11, 2005 5:59 AM by m m

    rmi over http troubles

    m m Newbie

      Hi all,
      we're using http tunneling to invoke ejbs, but we have some problems from outside the firewall.

      Client is configured like this:

      java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java.naming.provider.url=http://[public host name]/invoker/JNDIFactory

      Http invoker under jboss is configured in this way:

      [mbean code="org.jboss.invocation.http.server.HttpInvoker" name="jboss:service=invoker,type=http"]
      [attribute name="InvokerURL"]http://[public host name]/invoker/EJBInvokerServlet[/attribute]
      [/mbean]

      (replace "[" with xml tags)

      All working in lan, but while accessing from outside we get this exception:

      java.rmi.ConnectException: Connection refused to host: xxx.xx.xxx.xx; nested exception is: java.net.ConnectException: Connection refused: connect

      Where xxx.xx.xxx.xx is the internal ip address of the server.

      How can we solve this?
      Thanks in advice and sorry for my bad english.

      Bye


        • 1. Re: rmi over http troubles
          Dave Smith Newbie

          By default the system name where jboss is runnig is assumed to be the http target. Comment out InvokerURLPrefix,InvokerURLSuffix set UseHostName to false and then put the entire URL you wish to use as InvokerURL

          • 2. Re: rmi over http troubles
            m m Newbie

             

            "rimmeraj" wrote:
            By default the system name where jboss is runnig is assumed to be the http target. Comment out InvokerURLPrefix,InvokerURLSuffix set UseHostName to false and then put the entire URL you wish to use as InvokerURL


            As i wrote, my configuration is already like the one you suggest.

            [mbean code="org.jboss.invocation.http.server.HttpInvoker" name="jboss:service=invoker,type=http"]
            [attribute name="InvokerURL"]http://[public host name]/invoker/EJBInvokerServlet[/attribute]
            [/mbean]

            I removed prefix, port and useHostName attributes, and set the entire external url in the "InvokerURL" attribute.



            • 3. Re: rmi over http troubles
              Dave Smith Newbie

              Did you change the HttpProxyFactory mbean as well?

              • 4. Re: rmi over http troubles
                Kalyan Newbie

                Are you able to get to the page : http://[public host name] (from your URL) from outside? If not, you might have to look at this page: http://www.jboss.org/wiki/Wiki.jsp?page=UsingJBossBehindAFirewall

                Thanks,
                Kalyan.

                • 5. Re: rmi over http troubles
                  m m Newbie

                   

                  "kalyan120" wrote:
                  Are you able to get to the page : http://[public host name] (from your URL) from outside? If not, you might have to look at this page: http://www.jboss.org/wiki/Wiki.jsp?page=UsingJBossBehindAFirewall

                  Thanks,
                  Kalyan.


                  Yes i can reach the server, and i can reach the url http://[public server name]/invoker/JNDIFactory.

                  The problem is that the server is still returning the internal IP address instead of the url i specified in the "invokerUrl" attribute.

                  @rimmeraj
                  Yes i changed them all.

                  Thank you
                  Bye



                  • 6. Re: rmi over http troubles
                    Kalyan Newbie

                    The following is the method (in JBoss code) that's returning the internal ip address:

                    protected void checkInvokerURL() throws UnknownHostException
                     {
                     if( invokerURL == null )
                     {
                     InetAddress addr = InetAddress.getLocalHost();
                     String host = useHostName ? addr.getHostName() : addr.getHostAddress();
                     String url = invokerURLPrefix + host + invokerURLSuffix;
                     setInvokerURL(url);
                     }
                     }
                    


                    'useHostName' is by default set to false. So, you will have to set it to true inorder to be able to use the url you are wanting to use.

                    Thanks,
                    Kalyan.

                    • 7. Re: rmi over http troubles
                      m m Newbie

                       

                      "kalyan120" wrote:
                      The following is the method (in JBoss code) that's returning the internal ip address:

                      protected void checkInvokerURL() throws UnknownHostException
                       {
                       if( invokerURL == null )
                       {
                       InetAddress addr = InetAddress.getLocalHost();
                       String host = useHostName ? addr.getHostName() : addr.getHostAddress();
                       String url = invokerURLPrefix + host + invokerURLSuffix;
                       setInvokerURL(url);
                       }
                       }
                      


                      'useHostName' is by default set to false. So, you will have to set it to true inorder to be able to use the url you are wanting to use.

                      Thanks,
                      Kalyan.


                      That's right, but the invokerURL variable is set by the "InvokerUrl" xml parameter, so that "if" statement will get skipped.

                      Thank you
                      bye



                      • 8. Re: rmi over http troubles
                        Kalyan Newbie

                        I'm not sure if the setInvokerURL method is called after the startService method is called or not. If the startService method is called first and then the setInvokerURL is called later, your setting should work. Other way around, will not work for you. From your exception, it seems as if setInvokerURL is called before startService. Later once, startService is called, checkInvokerURL is called and then the invokerURL is set to the host address as the useHostName property is set to false.

                        Thanks,
                        Kalyan.

                        • 9. Re: rmi over http troubles
                          Kalyan Newbie

                          Oops!! Yes you are right. My logic is incorrect.

                          Thanks,
                          Kalyan.

                          • 10. Re: rmi over http troubles
                            m m Newbie

                            I solved this.

                            The problem was the ejb configuration in jboss.xml file, under the META-INF directory.

                            I used something like:



                            <ejb-name>ejb name</ejb-name>
                            <jndi-name>jndi name</jndi-name>
                            <local-jndi-name>jndi name</local-jndi-name>
                            <configuration-name>HTTP Session</configuration-name>


                            <container-configurations>
                            <container-configuration extends="Standard Stateless SessionBean">
                            <container-name>HTTP Session</container-name>
                            <home-invoker>jboss:service=invoker,type=http</home-invoker>
                            <bean-invoker>jboss:service=invoker,type=http</bean-invoker>
                            </container-configuration>
                            </container-configurations>


                            As described in many sites. This was working on LAN and was compatible with xdoclet tags generation.

                            To solve the problem, i have used something like this:



                            <ejb-name>ejb name</ejb-name>
                            <jndi-name>jndi name</jndi-name>
                            <local-jndi-name>jndi name</local-jndi-name> <invoker-bindings>

                            <invoker-proxy-binding-name>stateless-http-invoker</invoker-proxy-binding-name>

                            </invoker-bindings>


                            <invoker-proxy-bindings>
                            many tags here
                            </invoker-proxy-bindings>


                            As i found in a jboss guide. This wasn't compatible with xdoclet, but it has been quite simple to change jboss_xml.xdt to generate what i needed (thanks to google).

                            I hope this helps someone. For more details just ask.

                            Bye all