Using a custom security manager without defining a default policy causes AccessControlException

Solution Verified - Updated -

Issue

Trying to use a SecurityManager, like this [0]. It resulted in the following error, [1], being thrown.

[0]
From InformationClient.java:

     if (System.getSecurityManager() == null)

        {

            System.setSecurityManager(new java.rmi.RMISecurityManager());

        }

          try

          {

               Hashtable <String,String> properties = new Hashtable<String,String>();

               properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

               properties.put(Context.PROVIDER_URL, m_providerUrl);

               properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interface");

               InformationHome home = InformationUtil.getHome(properties);

               m_client = home.create();

          }

          catch (Exception e)

          {

               System.out.println("Exception: " + e.getMessage());

          }

[1]
WARN  [org.jboss.detailed.classloader.ClassLoaderManager] (main) Unexpected error during load of:com.jboss.example.ejb.stateless.InformationUtil
java.lang.Error: Error determining protection domain for ZipEntryHandler@399646848[path=test_aop.jar/com/jboss/example/ejb/stateless/InformationUtil.class context=file:/home/user/jboss-as/server/production/deploy-hasingleton/ real=file:/home/user/jboss-as/server/production/deploy-hasingleton/test_aop.jar/com/jboss/example/ejb/stateless/InformationUtil.class]
at org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.getProtectionDomain(VFSClassLoaderPolicy.java:665)
at ...
Caused by: java.security.AccessControlException: access denied (java.security.SecurityPermission getPolicy)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:393)
at java.security.AccessController.checkPermission(AccessController.java:553)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.security.Policy.getPolicy(Policy.java:151)
at org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.getProtectionDomain(VFSClassLoaderPolicy.java:660)
... 190 more

Environment

JBoss Enteprise Application Platform (EAP) 5.1

OpenJDK 1.6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.