[jboss-user] [JNDI/Naming/Network] - [Help] CommunicationException and AccessControlException: th

ShadenS do-not-reply at jboss.com
Wed Aug 2 11:53:31 EDT 2006


Hi JBoss Community :P

I've obtained two errors very famous, but I don't understand how to solve them by reading other posts. (example: http://www.jboss.org/?module=bb&op=viewtopic&t=68828

These exception are bind to java 's world (RMI ??), so I think someone here just has solution :)

Here exceptions (and then my ejb3 client... Ejb exposes a web services):

anonymous wrote :      [java] javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 a
  | nd 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 l
  | ocalhost:1099 [Root exception is java.security.AccessControlException: access denied (java.net.SocketPermission 127
  | .0.0.1:1099 connect,resolve)]]
  |      [java]     at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1414)
  |      [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
  |      [java]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
  |      [java]     at javax.naming.InitialContext.lookup(InitialContext.java:351)
  |      [java]     at bean.client.ClientToDeployBean.testWhatTimeAccess(ClientToDeployBean.java:20)
  |      [java]     at bean.client.ClientToDeployBean.main(ClientToDeployBean.java:63)
  |      [java] Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root except
  | ion is java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolv
  | e)]
  |      [java]     at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
  |      [java]     at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
  |      [java]     ... 5 more
  |      [java] Caused by: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:109
  | 9 connect,resolve)
  |      [java]     at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
  |      [java]     at java.security.AccessController.checkPermission(AccessController.java:427)
  |      [java]     at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
  |      [java]     at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034)
  |      [java]     at java.net.Socket.connect(Socket.java:501)
  |      [java]     at java.net.Socket.connect(Socket.java:457)
  |      [java]     at java.net.Socket.(Socket.java:365)
  |      [java]     at java.net.Socket.(Socket.java:265)
  |      [java]     at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
  |      [java]     at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
  |      [java]     at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:239)
  |      [java]     ... 6 more
  | 

My client:
package bean.client;
  | 
  | import java.rmi.RMISecurityManager;
  | import java.util.Hashtable;
  | 
  | import javax.ejb.Stateless;
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | import javax.xml.rpc.Service;
  | 
  | import src.jaws.WhatTimeService;
  | 
  | import bean.client.ClientToDeploy;
  | 
  | public @Stateless class ClientToDeployBean implements ClientToDeploy {
  | 
  | 	public void testWhatTimeAccess() throws Exception {
  | 		Context jndiContext = getInitialContext();
  | 		WhatTimeService service = (WhatTimeService) jndiContext.lookup("TimeAgentRemote");
  | 		System.out.println("dopo lookup!");
  | 		
  | 		/*InitialContext iniCtx = getInitialContext();
  | 		System.out.println("PASSO!");
  | 	    Service service = (Service)iniCtx.lookup("java:comp/env/service/TimeBean");
  | 	    System.out.println("PASSO2!");
  | 	  //  WhatTime port = (WhatTime)service.getPort(WhatTime.class);
  | 	    WhatTime service1 = (WhatTime)service;
  | 	     
  | 	    EndpointInterface end = service1.getEndpointInterfacePort();
  | 	   
  | 	    String ret = end.whatTimeIsIt("Dr. Emmett Brown");
  | 	       
  | 	       System.out.println(ret);*/
  | 	}
  | 	
  | 	
  | 	
  | 	protected InitialContext getInitialContext() throws NamingException{
  | 		//return new javax.naming.InitialContext();
  | 		System.setProperty("java.security.policy", "client.policy");
  | 		if (System.getSecurityManager() == null)
  | 		System.setSecurityManager(new RMISecurityManager());
  | 	
  | 		
  | 		InitialContext iniCtx = new InitialContext();
  | 	    iniCtx.addToEnvironment("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  | 	    Hashtable env = iniCtx.getEnvironment();
  | 	   // env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
  | 	    //env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
  | 	    env.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
  | 	    env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
  | 	    env.put("j2ee.clientName", "jbossws-client");
  | 	    env.put("java.naming.provider.url","localhost:1099");
  | 	    env.put("java.naming.factory.url.pkgs","org.jboss.naming.client");
  | 	    return new InitialContext(env);
  | 		
  | 	}
  | 	
  | 	public static void main(String [] args){
  | 		ClientToDeployBean ct = new ClientToDeployBean();
  | 		try{
  | 			ct.testWhatTimeAccess();
  | 		}catch(Exception e){
  | 			System.out.println("MAIN!");
  | 			e.printStackTrace();
  | 		}
  | 	}
  | 
  | }
  | 

Client explodes on this line:

WhatTimeService service = (WhatTimeService) jndiContext.lookup("TimeAgentRemote");

Thank you everyone! :_)


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962521#3962521

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962521



More information about the jboss-user mailing list