java.security.AccessControlException: Access denied (java.lang.RuntimePermission preferences)

Mikael Andersson Wigander picture Mikael Andersson Wigander · Feb 27, 2012 · Viewed 8.1k times · Source

I'm trying to run an Java agent from the console of the server and I get this Exception:

Agent Manager: Agent printing: WARN  AppLogger.java:246 initialize() Could not find a log4j.properties resource! Defaulting to app.log output. 
Agent Manager: Agent  error: Exception in thread "AgentThread: FTPBB" 
Agent Manager: Agent  error: java.lang.ExceptionInInitializerError
Agent Manager: Agent  error:  at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
Agent Manager: Agent  error:  at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
Agent Manager: Agent  error:  at com.bloomberg.datalic.api.ExtendedFTPConnection.<clinit>(ExtendedFTPConnection.java:2780)
Agent Manager: Agent  error:  at java.lang.J9VMInternals.initializeImpl(Native Method)
Agent Manager: Agent  error:  at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
Agent Manager: Agent  error:  at FTP.<init>(FTP.java:93)
Agent Manager: Agent  error:  at FTPBB.NotesMain(FTPBB.java:110)
Agent Manager: Agent  error:  at lotus.domino.AgentBase.runNotes(Unknown Source)
Agent Manager: Agent  error:  at lotus.domino.NotesThread.run(Unknown Source)
Agent Manager: Agent  error: Caused by: 
Agent Manager: Agent  error: java.security.AccessControlException: Access denied (java.lang.RuntimePermission preferences)
Agent Manager: Agent  error:  at java.security.AccessController.checkPermission(AccessController.java:108)
Agent Manager: Agent  error:  at java.lang.SecurityManager.checkPermission(SecurityManager.java:544)
Agent Manager: Agent  error:  at java.util.prefs.Preferences.userRoot(Preferences.java:443)
Agent Manager: Agent  error:  at com.bloomberg.datalic.util.DLPreferencesTree.<init>(DLPreferencesTree.java:29)
Agent Manager: Agent  error:  at com.bloomberg.datalic.util.DLPreferencesTree.getInstance(DLPreferencesTree.java:44)
Agent Manager: Agent  error:  at com.bloomberg.datalic.util.DLPreferenceNode.<clinit>(DLPreferenceNode.java:19)
Agent Manager: Agent  error:  at java.lang.J9VMInternals.initializeImpl(Native Method)
Agent Manager: Agent  error:  at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
Agent Manager: Agent  error:  ... 8 more

The agent uses two external jar-libraries from Bloomberg. These two are imported into the agent and also placed in the domino/jvm/lib directory on the server.

The exception is thrown when calling the class constructor of one of the classes in the imported library.

The agent runs fine when running it manually in the Designer client.

I think I must edit java.pol* files but my experience here i quite limited, I'm afraid…

Please advice

/Mike

Answer

Robert J Saulnier picture Robert J Saulnier · Feb 27, 2012

You're missing the preferences RuntimePermission:

java.security.AccessControlException: Access denied (java.lang.RuntimePermission preferences)

The minimum you need to do is add a RuntimePermission to your policy file:

grant {
    permission java.lang.RuntimePermission "preferences";
};

Once you get past this exception, you'll probably get more, but it's better than allowing all permissions.