0

I am developing an enterprise application using RMI, and I get an error while trying to (re)bind the object :

Naming.rebind(url, this);

// The object "this" is a subclass of UnicastRemoteObject Before this instruction I create a new RMISecurityManager with :

if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
}

The exact error is :

[err] java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.reflect")

I am developing on WAS Liberty Profile 8.5.5. I tried to create java.policy, app.policy, was.policy, server.policy in the META-INF folder of the EAR project, without any success.

I tried to set the file with the instruction : System.setProperty("java.security.policy", ".../security/java.policy"); And with that, it worked !

What am I missing ? (as this last solution worked, I assume that the java.policy file is well formed and efficient, so it's just about the way to include this file into my ear file and to be taken in configuration into WAS...) Thank you.

user207421
  • 305,947
  • 44
  • 307
  • 483
horfee
  • 19
  • 4

1 Answers1

0

Taken from the Info Center the correct place for the was.policy file in an ear archive is META-INF/was.policy however there may be more to it. "An application EAR file is now ready to run when Java 2 security is enabled." So Java 2 security must be enabled.

Also not all keywords that are accepted in java.policy works in was.policy (also as described in the Info Center) so you should probably verify that your was.policy file does not use any unsupported syntax. More about the was.policy file here.

DanielBarbarian
  • 5,093
  • 12
  • 35
  • 44