The Java Coffee Cup Logo

Remote Debugging of Java Applications

At work I tried to debug the Java application that we provide to our customers. A nasty performance problem had developed in the course of time. To analyze this, I can recommend using VisualVM. It’s part of Oracle’s JDK (version 6 and up) but is also available as a stand alone download.

VisualVM also allows for remote debugging an application. To this end you can use the “jstatd” application, also part of Oracle’s JDK. When I used this app for some testing, I encountered the following exception at start up:

Could not create remote object
access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)
java.security.AccessControlException: access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:536)
at java.lang.System.setProperty(System.java:699)
at sun.tools.jstatd.Jstatd.main(Jstatd.java:122)

Vinay Singla has the answer on his blog. He explains that to run the application requires some permissions before it can run:

Cause :- The “access denied” error is expected, because “jstatd” requires a security policy file specified with the “java.security.policy” system property, if there is no security manager running on the machine.

His solution (as ‘translated to a Windows environment’, by me):

  1. Inside a DOS-box/Console, change to the bin directory, inside the JDK directory. (e.g. c:\program files\java\jdk7\bin)
  2. Check if a file exists with the name “jstatd.all.policy”. If not, create it with Notepad. If so, edit it with Notepad.
  3. Add this information to the file:
    grant codebase “file:${java.home}/../lib/tools.jar” {
    permission java.security.AllPermission;
    };
  4. Run this command: jstatd -J-Djava.security.policy=jstatd.all.policy
  5. Now you can connect to this machine via VisualVM.

Via http://dbafusion.blogspot.nl/2010/05/jstad-error-could-not-create-remote.html