9 Replies Latest reply on Sep 11, 2003 9:49 AM by twutort

    JNDI over http

    uramisten

      help.. can someone summarize what I need to do to get jndi running over http? I have tried changing the jndi.properties file.. but then I get can't connect to port 1099 errors, etc etc... What else am I missing? I'm guessing it may be something from the JDNI section in the jboss-server.xml file... but I'm clueless..

      plz help
      thnx.
      Ati

        • 1. Re: JNDI over http
          frito

          These properties must be set on the client who is doing the lookup (JB 3.x, default or all configuration):
          [pre]
          java.naming.factory.initial=org.jboss.naming.HttpNamingContextFactory
          java.naming.provider.url=http://:8080/invoker/JNDIFactory
          java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
          [/pre]
          No changes to your code are required.

          Greetings,
          Frito

          • 2. Re: JNDI over http
            bentzn

            Yes!

            Great, that's what I've been looking for....

            -only one thing.... My firewall still has to have high ports (>1024) open if I want it to work...

            It seems to me, that after the first connection is established over http (port 8080) then a second connection on a random portnumber starts....

            I have no probs with the load (yet) so could I maybe assign a fixed portnumber to that second connection - it's beacuse I use another machine to make the filtering/routing with SuSE Firewall2


            Thanks

            b

            • 3. Re: JNDI over http
              frito

              You are only looking up over http. The bean call later on is standard RMI, this means at least two ports, one of these dynamically changing every time you start JBoss, are used.
              We are doing bean calls from behind a firewall using the SSL invoker. Search the forum or read the JBoss book (chapter 8 - Using SSL with JBoss using JSSE). You only need to open one port for the SSL invoker and this approach is much more performant than another possibility: HTTP tunneling.

              Greetings,
              Frito

              • 4. Re: JNDI over http
                mikesu

                Could you please elaborate?

                • 5. Re: JNDI over http
                  bentzn

                  Thanks!

                  I'll look into the JSSE-thing...

                  I just discovered that I can't make a lookup from outside the firewall at all....

                  Am I missing something or is the communication inside my regular TCP/IP ethernetwork the same as on the internet - ie. outside my firewall...?

                  • 6. Re: JNDI over http
                    bentzn

                    'elaborate'... I guess it's me.... :-)

                    I'm using JBoss as an EJB-server.
                    Login is performed with JAAS (client-loginmodule and so on)


                    And then I make a lookup:
                    Properties env = new Properties();

                    env.setProperty("java.naming.factory.initial", "org.jboss.naming..HttpNamingContextFactory");

                    env.setProperty("java.naming.provider.url", "http://62.107.81.101:8080/invoker/JNDIFactory");

                    env.setProperty("java.naming.url.pkgs", "org.jboss.naming:org.jboss.jnp.interface");

                    InitialContext iCtx = new InitialContext(env);

                    Object ref = iCtx.lookup("nameOfBean");

                    EJBHome home = (EJBHome)PortableRemoteObject.narrow(ref, EJBHome.class);


                    I have a computer on the internal network where I've developed everthing - and everything works fine on that one...
                    -and then I have another computer with it's own connection to the internet for testing - and nothing works on that one - well, that is, the Tomcat-server on port 8080 works fine.

                    Firewall on the server is set (right now) to open ports 80 and 1024:65000 and iptables redirect port 80 to 8080


                    Any help would be greatly appreciated... I'm going on vacations tomorrow.... - if I get this working... :-)


                    thanks

                    b

                    • 7. Re: JNDI over http
                      bentzn

                      I've been looking at JSSE - the chapter in the book and the very little in the forums...
                      - and I can't get it working...
                      Maybe I'm just too tired...
                      I have added the jboss-service.xml-example in the book to the Tomcat jboss-service.xml:


                      <!-- The SSL domain setup -->




                      my.keystore
                      mypasswd


                      4445
                      org.jboss.security.ssl.RMISSLClientSocketFactory
                      org.jboss.security.ssl.RMISSLServerSocketFactory
                      java:/jaas/MYDOMAIN
                      jboss.security:service=JaasSecurityDomain,domain=MYDOMAIN



                      -where MYDOMAIN is an application-policy in login-config.xml
                      and it throws an NameNotFoundException because it can't find MYDOMAIN


                      -anyway a sample or simple explanation of domains, keystores and so on would come in handy... :-)


                      best

                      b



                      PS Am I completely wrong here?!
                      I wanted to make a 'traditional' client/server thing communicating over
                      the internet and it seems to be at best dificult - maybe even impossible....?!

                      • 8. Re: JNDI over http
                        twutort

                        I'm having this same error and can not figure it out. When I attempt to lookup an object I get "Failed to connect to server http:1099". I trying to do the look up using the http protocol over port 8080. Is there some setting I need? Here is my lookup code:

                        Properties env = new Properties();

                        env.setProperty("java.naming.factory.initial", "org.jboss.naming..HttpNamingContextFactory");

                        env.setProperty("java.naming.provider.url", "http://loclahost:8080/invoker/JNDIFactory");

                        env.setProperty("java.naming.url.pkgs", "org.jboss.naming:org.jboss.jnp.interface");

                        InitialContext iCtx = new InitialContext(env);

                        Object ref = iCtx.lookup("classA");

                        • 9. Re: JNDI over http
                          twutort

                          I got this to work by removing the following property:

                          env.setProperty("java.naming.url.pkgs", "org.jboss.naming:org.jboss.jnp.interface");

                          From the documentation it gathered that I needed this property. However, I noticed this property was not set in the examples. So I removed it and it worked. WHy is this? Is it because the url.pkgs property says to use jnp? Perhaps I misread the documentation and assumed I needed that property for http.

                          Thanks,
                          Tim