client jmx through httpinvoker
sviluppatorefico Jul 7, 2005 11:07 AMhi.....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.