I'm not sure you can. I think this kind of behaviour (i.e. opening sockets
to remote registries) is explicitly forbidden in section 18.1.2 of the EJB
1.1 spec.

Friedrich Dodt wrote:

> How do I get my Session Bean to issue an RMI call successfully?
>
> I am trying to contact a simple RMI method that runs on an RMI server
> (rmiregistry) from code in my Session Bean. Up to now without success.
>
> 1. With the naive approach
>
>         System.setSecurityManager(new RMISecurityManager());
>         RemoteObject remo = (RemoteObject) Naming.lookup(toLookup);
>
> I get a  (java.net.SocketPermission xxx.xxx.xxx.xxx:xxxx
> connect,resolve)
>
> To overcome this, I have changed
> - {java.home}/lib/security/java.policy
> - and I have tried it the with the command line arguments
>         -Djava.security.manager -Djava.security.policy==my.policy
>   when I start orion.jar.
>
> This policy file contained just
>
> grant {
>         // Allow everything for now
>         permission java.security.AllPermission;
>         permission com.evermind.server.AdministrationPermission;
>         permission java.net.SocketPermission "*:1024-65535",
> "listen,accept,connect,resolve";
> };
>
> However, this didn't change Orions behaviour.
>
> The approach with
>         // create and fill a Hashtable "environment", then call
>         InitialContext context = new InitialContext (environment);
> didn't work either.
>
> 2. Suspecting that the Orion server interferes with the normal policy
> concept, I tried to change the rmi.xml file.
>
> The mere adding of a line like
>
> <server host="localhost" username="admin" password="admin" />
>
> to rmi.xml leads to the server not starting up. It does not say "Orion
> 1.0.3 initialized" and it does not react (in the case rmiregistry runs;
> if not an Exception is thrown indicating the connection is refused).
>
> This is clearly a bug: If the server can't cope with a situation it
> should at least leave a message and not just be stuck silently. This is
> true if you start Orion just as it ships with just the rmi.xml changed.
>
> So the question is: How can I contact an RMI server from within an EJB?
>
> If you don't know that, perhaps you can answer this one: How can I
> permit SocketPermission (and other permissions?) to the code in my EJB?
>
> Thanks in advance
begin:vcard 
n:Smith;Dave
tel;cell:+44 797 0008867
tel;work:+44 1225 445610
x-mozilla-html:TRUE
url:http://www.enetgroup.co.uk
org:e-net Software Ltd
adr:;;26-45 Cheltenham Street;Bath;;BA2 3EX;
version:2.1
email;internet:[EMAIL PROTECTED]
title:Software Development Manager
fn:Dave Smith
end:vcard

Reply via email to