2 Replies Latest reply on Aug 7, 2005 1:05 PM by nehring

    client jmx through httpinvoker

    sviluppatorefico

      hi.....I use jboss4.0.2 and I've configured httpinvoker of type "restricted" . I want to call it through a java client. I've tried to make this:

      Properties ps = new Properties();
      ps.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.HttpNamingContextFactory");
      ps.setProperty(Context.PROVIDER_URL,"http://localhost:8080/restricted/JNDIFactory");
      InitialContext ic = new InitialContext(ps);
      Object server = (Object)ic.lookup("jmx/invoker/RMIAdaptor");
      System.out.println(server);


      I've this error:

      Exception in thread "main" javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.net.ProtocolException: Server redirected too many times (20)]
       at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:69)
       at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
       at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
       at javax.naming.InitialContext.init(InitialContext.java:223)
       at javax.naming.InitialContext.<init>(InitialContext.java:197)
       at client.Main.main(Main.java:36)
      Caused by: java.net.ProtocolException: Server redirected too many times (20)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
       at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1202)
       at java.security.AccessController.doPrivileged(Native Method)
       at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1196)
       at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:885)
       at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:118)
       at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:65)
       ... 5 more
      Caused by: java.net.ProtocolException: Server redirected too many times (20)
       at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1157)
       at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:1866)
       at java.net.URLConnection.getHeaderFieldInt(URLConnection.java:573)
       at java.net.URLConnection.getContentLength(URLConnection.java:468)
       at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:113)
       ... 6 more



      if I invoke restricted/JNDIFactory through the web browser I succeed to download it with an authentication. I ask me too how I can to pass the credentials through the java code.




        • 1. Re: client jmx through httpinvoker
          riyaz_ahmed_mansur


          use this
          initialContext ic = new initialContext(env);
          RMIAdaptor server = (RMIAdaptor ic.lookup("jmx/invoker/RMIAdaptor");

          • 2. Re: client jmx through httpinvoker
            nehring

            If your JBoss server is running on a windows machine. You may have to check the 'jboss-service.xml' file in the 'http-invoker.sar/META-INF' directory of your JBoss server configuration.

            I've seen that a the windows server hostname may default to it's short name or DNS alias. When the client asks the server for the Naming service the server responds with a URL containing the short name. The client most likely can't resolve the short name into an IP address.

            The 'jboss-service.xml' file has attributes named 'UseHostName' in the MBean definitions. They are set to 'true' by default and I generally set them to 'false' for windows machines that have this problem with host name.

            If you use a network sniffer, i.e. ethereal, you can verify the behavior and see what the server is sending back to the client.

            r,
            Lance