6 Replies Latest reply on Mar 3, 2004 1:50 AM by themuppeteer

    EJB-lookup over HTTP

    Thomas Bentsen Newbie

      I've been challenged by this problem for about two weeks now:

      I want to make an EJB-connection to JBoss 3.2.1 over HTTP
      When I'm on my internal network everything works fine
      - also when I make the firewall on the server protect from the internal network.

      As soon as I go on the internet nothing works!
      It hangs there for quite some time and then I get a
      java.lang.reflect.InvocationTargetException.


      In the following:
      server = 102.102.102.102
      client = 212.212.212.212


      The lookup of the client:
      Properties env = new Properties();
      env.setProperty("java.naming.factory.initial", "org.jboss.naming.HttpNamingContextFactory");
      env.setProperty("java.naming.provider.url", "http://102.102.102.102:8080/invoker/JNDIFactory");
      env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      InitialContext iCtx = new InitialContext(env);


      The Exception:
      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      ...
      ...


      JBoss' access-log:
      212.212.212.212 - - [13/Aug/2003:11:48:10 1000] "GET /invoker/JNDIFactory HTTP/1.1" 200 1279
      212.212.212.212 - - [13/Aug/2003:11:48:10 1000] "POST /invoker/JMXInvokerServlet HTTP/1.1" 200 2447
      212.212.212.212 - - [13/Aug/2003:11:48:31 1000] "GET /invoker/JNDIFactory HTTP/1.1" 200 1279
      212.212.212.212 - - [13/Aug/2003:11:48:31 1000] "POST /invoker/JMXInvokerServlet HTTP/1.1" 200 2447


      When I try http://102.102.102.102:8080/invoker/JNDIFactory in a browser I get:
      xpt 3http://102.102.102.102:8080/invoker/JMXInvokerServletxsq ~

      among other stuff...


      I can see in the access-log that there is a connection and
      in the access-log of the server that the connection is on
      ports 8080 and 4445 as it is supposed to be, but from there I'm clueless.


      Server is Suse Linux 8.1
      - firewall is set to filter everything else than 80, 4445 and 8080
      also it redirects port 80 to 8080

      Clients are MS XP Pro

      My internet-connection on both the server and clients
      is a cable-modem


      I really hope somebody can help :-)


      PS I wanted to attach my jboss-service.xml-files but I got IndexOutOfBoundsException.... :-)

        • 1. Re: EJB-lookup over HTTP
          Adrian Brock Master

          Post your jboss-service.xml in line.

          So you can make connections on 4445 (you have specified
          this port on the jrmp invoker in jboss-service.xml)

          Any reason why you are using HTTP for jndi and
          RMI for ejbs?

          Regards,
          Adrian

          • 2. Re: EJB-lookup over HTTP
            Thomas Bentsen Newbie

            HTTP was recommended if I wanted to pass my firewall, but it seems to me that my problems has nothing to do with that.

            The thing is: I started using JBoss some weeks ago for a project I'm about to finish.
            Everything was testet over my internal network and worked fine - and I honestly thought it would be a matter of minutes to deploy my client and access my applicationserver over the internet.
            But no...
            As a part of the problem-solving I changed to HTTP.

            The ultimate goal for me is to make that same kind of connection over the net as on my LAN. Don't really care what flavour it has. :-)

            Maybe I should tell you that I have two IP-addresses on my server - one internal and one external. There seems to be some confusion about what IP-address JBoss is using.


            My jboss-service.xml:
            ===========================

            <?xml version="1.0" encoding="UTF-8" ?>
            <!DOCTYPE server (View Source for full doctype...)>
            - <!-- $Id: jboss-service.xml,v 1.59.2.22 2003/04/13 19:57:10 slaboure Exp $
            -->
            - <!-- =====================================================================
            -->
            - <!--
            -->
            - <!-- JBoss Server Configuration
            -->
            - <!--
            -->
            - <!-- =====================================================================
            -->
            -
            - <!--
            Load all jars from the JBOSS_DIST/server//lib directory. This
            can be restricted to specific jars by specifying them in the archives
            attribute.


            -->

            - <!--
            Preload all custom editors for VMs that don't use the thread
            context class loader when searching for PropertyEditors. Uncomment
            if your JDK 1.3.0 VM fails to find JBoss PropertyEditors.


            java.math.BigDecimal=org.jboss.util.propertyeditor.BigDecimalEditor
            java.lang.Boolean=org.jboss.util.propertyeditor.BooleanEditor
            java.lang.Class=org.jboss.util.propertyeditor.ClassEditor
            java.util.Date=org.jboss.util.propertyeditor.DateEditor
            java.io.File=org.jboss.util.propertyeditor.FileEditor
            java.net.InetAddress=org.jboss.util.propertyeditor.InetAddressEditor
            java.lang.Integer=org.jboss.util.propertyeditor.IntegerEditor
            javax.management.ObjectName=org.jboss.util.propertyeditor.ObjectNameEditor
            java.util.Properties=org.jboss.util.propertyeditor.PropertiesEditor
            [Ljava.lang.String;=org.jboss.util.propertyeditor.StringArrayEditor
            java.net.URL=org.jboss.util.propertyeditor.URLEditor




            -->
            - <!-- ====================================================================
            -->
            - <!-- Log4j Initialization
            -->
            - <!-- ====================================================================
            -->
            -
            resource:log4j.xml
            - <!--
            Set the org.apache.log4j.helpers.LogLog.setQuiteMode. As of log4j1.2.8
            this needs to be set to avoid a possible deadlock on exception at the
            appender level. See bug#696819.


            -->
            true

            - <!-- ====================================================================
            -->
            - <!-- JBoss RMI Classloader - only install when available
            -->
            - <!-- ====================================================================
            -->
            -
            java.rmi.server.RMIClassLoaderSpi
            org.jboss.system.JBossRMIClassLoader

            - <!-- ====================================================================
            -->
            - <!-- Service Binding
            -->
            - <!-- ====================================================================
            -->
            - <!-- Automatically activated when generatting the clustering environment
            -->
            - <!-- @TESTSUITE_CLUSTER_CONFIG@
            -->
            - <!--
            | Binding service manager for port/host mapping. This is a sample
            | config that demonstrates a JBoss instances with a server name 'jboss1'
            | loading its bindings from an XML file using the ServicesStoreFactory
            | implementation returned by the XMLServicesStoreFactory.
            |
            | ServerName: The unique name assigned to a JBoss server instance for
            | lookup purposes. This allows a single ServicesStore to handle mulitiple
            | JBoss servers.
            |
            | StoreURL: The URL string passed to org.jboss.services.binding.ServicesStore
            | during initialization that specifies how to connect to the bindings store.
            | StoreFactory: The org.jboss.services.binding.ServicesStoreFactory interface
            | implementation to create to obtain the ServicesStore instance.


            jboss1
            file:/etc/jboss-bindings.xml

            org.jboss.services.binding.XMLServicesStoreFactory





            -->
            - <!-- ====================================================================
            -->
            - <!-- Class Loading
            -->
            - <!-- ====================================================================
            -->
            -
            8083
            - <!-- Should resources and non-EJB classes be downloadable
            -->
            true

            - <!-- ====================================================================
            -->
            - <!-- JSR-77 Single JBoss Server Management Domain
            -->
            - <!-- ====================================================================
            -->
            -
            jboss.system:service=MainDeployer
            jboss.system:service=ServiceDeployer
            jboss.j2ee:service=EARDeployer
            jboss.ejb:service=EJBDeployer
            jboss.jca:service=RARDeployer
            jboss.jca:service=ConnectionFactoryDeployer
            jboss.web:service=WebServer
            jboss:service=Mail
            jboss.mq:service=DestinationManager
            jboss:service=Naming
            jboss:service=TransactionManager
            jboss:service=ClientUserTransaction

            - <!-- ====================================================================
            -->
            - <!-- JNDI
            -->
            - <!-- ====================================================================
            -->
            -
            - <!--
            The listening port for the bootstrap JNP service. Set this to -1
            to run the NamingService without the JNP invoker listening port.


            -->
            1099
            - <!--
            10990


            -->


            - <!-- ====================================================================
            -->
            - <!-- Security
            -->
            - <!-- ====================================================================
            -->
            -
            jboss.security:service=XMLLoginConfig

            -
            login-config.xml

            - <!-- JAAS security manager and realm mapping
            -->
            -
            org.jboss.security.plugins.JaasSecurityManager

            - <!-- ====================================================================
            -->
            - <!-- The deployers...
            -->
            - <!-- ====================================================================
            -->
            - <!-- EJB deployer, remove to disable EJB behavior
            -->
            -
            true
            false
            false
            true
            - <!--
            StrictVerifier: Setting this to 'true' will cause all deployments
            to fail when the Verifier detected a problem with the contained
            Beans.


            -->
            true
            <depends optional-attribute-name="TransactionManagerServiceName">jboss:service=TransactionManager
            <depends optional-attribute-name="WebServiceName">jboss:service=WebService

            - <!-- EAR deployer, remove if you are not using Web layers
            -->


            - <!-- ====================================================================
            -->
            - <!-- Monitoring and Management
            -->
            - <!-- ====================================================================
            -->
            - <!--
            Uncomment to enable JMX monitoring of the bean cache



            -->
            - <!--
            Uncomment to enable JMX monitoring of the entity bean locking



            -->
            - <!-- ====================================================================
            -->
            - <!-- Invokers to the JMX node
            -->
            - <!-- ====================================================================
            -->
            - <!-- RMI/JRMP invoker
            -->
            -
            4445
            - <!--
            custom
            custom
            custom
            ssl-domain-name


            -->
            jboss:service=TransactionManager

            -
            jboss:service=TransactionManager

            -
            1
            300
            300
            60000

            0

            0
            false
            <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager

            - <!-- ====================================================================
            -->
            - <!-- Deployment Scanning
            -->
            - <!-- ====================================================================
            -->
            - <!--
            Uncomment to enable caching of deployment units

            data/deployment-cache



            <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer
            <depends optional-attribute-name="Store">jboss.deployment:type=DeploymentStore,flavor=File



            -->
            - <!--
            An mbean for hot deployment/undeployment of archives.


            -->
            -
            - <!--
            Uncomment (and comment/remove version below) to enable usage of the
            DeploymentCache
            <depends optional-attribute-name="Deployer">jboss.deployment:type=DeploymentCache


            -->
            <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer
            - <!--
            The URLComparator can be used to specify a deployment ordering
            for deployments found in a scanned directory. The class specified
            must be an implementation of java.util.Comparator, it must be able
            to compare two URL objects, and it must have a no-arg constructor.
            Two deployment comparators are shipped with JBoss:
            - org.jboss.deployment.DeploymentSorter
            Sorts by file extension, as follows:
            "sar", "service.xml", "rar", "jar", "war", "wsr", "ear", "zip",
            "*"
            - org.jboss.deployment.scanner.PrefixDeploymentSorter
            If the name portion of the url begins with 1 or more digits, those
            digits are converted to an int (ignoring leading zeroes), and
            files are deployed in that order. Files that do not start with
            any digits will be deployed first, and they will be sorted by
            extension as above with DeploymentSorter.


            -->
            org.jboss.deployment.DeploymentSorter
            - <!--
            org.jboss.deployment.scanner.PrefixDeploymentSorter


            -->
            - <!--
            The Filter specifies a java.io.FileFilter for scanned
            directories. Any file not accepted by this filter will not be
            deployed. The org.jboss.deployment.scanner.DeploymentFilter
            rejects the following patterns:
            "#*", "%*", ",*", ".*", "_$*", "*#", "*$", "*%", "*.BAK",
            "*.old", "*.orig", "*.rej", "*.bak", "*,v", "*~", ".make.state",
            ".nse_depinfo", "CVS", "CVS.admin", "RCS", "RCSLOG", "SCCS",
            "TAGS", "core", "tags"


            -->
            org.jboss.deployment.scanner.DeploymentFilter
            5000
            - <!--
            URLs are comma separated and resolve relative to the server home URL
            unless the given path is absolute. If the URL ends in "/" it is
            considered a collection and scanned, otherwise it is simply deployed;
            this follows RFC2518 convention and allows discrimination between
            collections and directories that are simply unpacked archives.

            URLs may be local (file:) or remote (http:). Scanning is supported
            for remote URLs but unpacked deployment units are not.

            Example URLs:
            deploy/
            scans ${jboss.server.url}/deploy/, which is local or remote
            depending on the URL used to boot the server
            ${jboss.server.home}/deploy/
            scans ${jboss.server.home)/deploy, which is always local
            file:/var/opt/myapp.ear
            deploy myapp.ear from a local location
            file:/var/opt/apps/
            scans the specified directory
            http://www.test.com/netboot/myapp.ear
            deploys myapp.ear from a remote location
            http://www.test.com/netboot/apps/
            scans the specified WebDAV location


            -->
            deploy/
            - <!--

            Indicates if the scanner should recursively scan directories that contains no "." in their names.
            This can be used to group applications/services that must be deployed and that have the same
            logical function in the same directory i.e.
            deploy/JMX/
            deploy/JMS/
            ...


            -->
            False

            - <!--
            An alternate hot deployer mbean. Use URLDirectoryScanner if you need to
            specify which urls are directories to scan, and which are urls to be
            deployed directly. URLDeploymentScanner assumes that all directories are to
            be scanned, which can cause problems if directory referred to in the
            deploy attribute is an exploded archive.


            <depends optional-attribute-name="Deployer">jboss.system:service=MainDeployer
            org.jboss.deployment.DeploymentSorter
            org.jboss.deployment.scanner.DeploymentFilter
            5000
            /* Each entry specifies either a dir (directory to be scanned),
            or url (url to be deployed). Like the URLs for the DeploymentScanner
            above, a file: protocol will be assumed if not specified otherwise.
            */











            -->

            • 3. Re: EJB-lookup over HTTP
              Jan Radl Newbie

              I thing the problem is not about looking up a EJB in JNDI over http but to invoke ejb method over the http. Am I right ?

              This problem is common for distributed systems like CORBA, EJB etc. If you want to use rmi or iiop invocation over http you have to wrap these protocols in http protocol on client side and unmarshall them on server side. The proble is that the http is not keep connection for all that time and also does not keep any session info.

              Second problem is inside and outside IP address or NAT problem. You can put some proxy plugin into the firewall that change the inside address in the protocol (iiop or rmi) to outside address that is reachable from internet. We work on this proxy for more than 3 months and within 3 weeks we will test the first release of this product. Or you can purchase Xtradyne DBC (http://www.xtradyne.com/)

              Good luck

              Jan

              • 4. Re: EJB-lookup over HTTP
                Adrian Brock Master

                You probably want to use the
                -Djava.rmi.server.hostname system property
                to make rmi use hostnames instead of ip addresses
                if you have two nics.

                Regards,
                Adrian

                • 5. Re: EJB-lookup over HTTP
                  Thomas Bentsen Newbie

                  Thanks for your help!

                  Everything works fine now.
                  It was actually a question of setting up the hostname and the right address in http-invoker

                  • 6. Re: EJB-lookup over HTTP
                    themuppeteer Newbie

                    Hello bentz,

                    Have you already found a solution for having a connection over the net instead of the lan?
                    I have practiacally the same problem, I also want a client to connect to my application server over the internet and it also doesn't work.

                    Best regards,
                    themuppeteer

                    (NOSPAM_themuppeteer_NOSPAM@hotmail.com remove the _nospam_ stuff for mails)