Tomcat – java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)

Problem

As i said in previously post, Tomcat 5.5.25 made a lot of modification in policy file, which may enhance security on web application but it also causing a lot of problem, see another error message :


SEVERE: Context initialization failed java.security.AccessControlException: 
      access denied (java.lang.RuntimePermission accessDeclaredMembers) at           
      java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)

Solution

Policy file issue, vi 04webapps.policy, this file is usually located at policy.d folder


mkyong@mkyong-desktop:/etc/tomcat5.5/policy.d$ 04webapps.policy

add following statement into the policy file


permission java.lang.RuntimePermission "accessDeclaredMembers";

For example,

File : 04webapps.policy


    // JVM properties to allow read access
    permission java.util.PropertyPermission "java.version", "read";
    permission java.util.PropertyPermission "java.vendor", "read";
    //omitted for readability 
    // Precompiled JSPs need access to this package.
    permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime";
    permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime.*";

    permission java.lang.RuntimePermission "accessDeclaredMembers";
};

Saved it, restart Tomcat and Done.

author image

mkyong

Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities. Read all published posts by

Comments

avatar
3000
newest oldest most voted
rganeshbabu
Guest
rganeshbabu

I will be created PDF File in Runtime Applet Window (Button Click Event). I face this error:

“java.security.accesscontrolexception access denied (java.lang.runtimepermission getenv.*) in Applet Window”

Code
———-
.
.
.
pdfFile = new File(System.getenv(“Temp”) + File.separator + “Filename.pdf”);
if (pdfFile.exists())
{
if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().open(pdfFile);
}
}

rganeshbabu
Guest
rganeshbabu

I will be created PDF File in Runtime Applet Window (Button Click Event). I face this error:

“java.security.accesscontrolexception access denied (java.lang.runtimepermission getenv.*) in Applet Window”

Code
———-
.
.
.
pdfFile = new File(System.getenv(“Temp”) + File.separator + “Filename.pdf”);
if (pdfFile.exists())
{
if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().open(pdfFile);
}
}

rganeshbabu
Guest
rganeshbabu

java.security.accesscontrolexception access denied (java.lang.runtimepermission getenv.*) in Applet Window.

Ganesh
Guest
Ganesh

java.security.accesscontrolexception access denied (java.lang.runtimepermission getenv.*) in Applet Window.

Jassyr Juárez
Guest
Jassyr Juárez

Well, it depends, in my case im deploying an application through JWS and i got that message. My app contains a web service client and i needed some jars to connect the server.
The problem was that the jnlp file was missing the section:


Of course, the jars are signed in order to run without problems. Once i added that instructions the exception gone.

Btw, I didn’t need to modify any policy file.

Jassyr Juárez
Guest
Jassyr Juárez

I dont know what happened with the code.

Just add the all-permissions tag inside security tag.

More info:

http://download.oracle.com/javase/tutorial/deployment/webstart/security.html

trackback
Tomcat 5.5.25 is suck… Give Up

[…] java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMemb… […]

SJK
Guest
SJK

this dosent work!!!