How can a standalone client access JBoss JNDI bindings content? The standalone client code below works find with other application servers (WebLogic, Sun) but not with JBoss.
The first error when running the client is: java.lang.ClassNotFoundException: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory (no security manager: RMI class loader disabled)] After adding a security manager and a policy file to the standalone client there is a second error: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) ____________________ Below are the code and the stacktraces of the two versions of the standalone client one blank the other with security manager settings. Standalone client without security manager settings: package test; import java.util.Properties; import javax.naming.Binding; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingEnumeration; import javax.naming.NamingException; public class ListJNDIBindings { public static void main(String[] args) { Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, org.jnp.interfaces.NamingContextFactory.class.getName()); props.put(Context.PROVIDER_URL, "jnp://localhost:1099"); props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); try { Context context = new InitialContext(props); NamingEnumeration ne = context.listBindings(""); while (ne.hasMore()) { System.out.println(ne.nextElement()); } } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } Stacktrace: javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory (no security manager: RMI class loader disabled)] at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:966) at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:915) at javax.naming.InitialContext.listBindings(InitialContext.java:406) at test.ListJNDIBindings.main(ListJNDIBindings.java:27) Caused by: java.lang.ClassNotFoundException: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory (no security manager: RMI class loader disabled) at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:371) at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165) at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620) at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247) at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348) at java.rmi.MarshalledObject.get(MarshalledObject.java:135) at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72) at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:962) ... 3 more Standalone client with security manager settings: Policy file: grant { permission java.security.AllPermission; }; Standalone client code: package test; import java.rmi.RMISecurityManager; import java.util.Properties; import javax.naming.Binding; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingEnumeration; import javax.naming.NamingException; public class ListJNDIBindings { public static void main(String[] args) { System.setProperty("java.security.policy", "client.policy"); if (System.getSecurityManager() == null) System.setSecurityManager(new RMISecurityManager()); Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, org.jnp.interfaces.NamingContextFactory.class.getName()); props.put(Context.PROVIDER_URL, "jnp://localhost:1099"); props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); try { Context context = new InitialContext(props); NamingEnumeration ne = context.listBindings(""); while (ne.hasMore()) { System.out.println(ne.nextElement()); } } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } Stacktrace: javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery failed with error: java.security.AccessControlException: access denied (java.net.SocketPermission 230.0.0.4 connect,accept,resolve) [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)]] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562) at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:922) at org.jnp.interfaces.NamingContext.listBindings(NamingContext.java:915) at javax.naming.InitialContext.listBindings(InitialContext.java:406) at test.ListJNDIBindings.main(ListJNDIBindings.java:27) Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274) at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533) ... 4 more Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264) at java.security.AccessController.checkPermission(AccessController.java:427) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034) at java.net.Socket.connect(Socket.java:513) at java.net.Socket.connect(Socket.java:469) at java.net.Socket.(Socket.java:366) at java.net.Socket.(Socket.java:266) at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84) at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77) at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:244) ... 5 more View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112092#4112092 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112092 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user