cannot start jstatd due to permission error

后端 未结 11 1073
野的像风
野的像风 2020-12-12 10:59

I try to run jstatd jvm monitoring tool on linux machine

jboss@hostAddr:/usr/java/jdk1.6.0_18/bin> uname -a
Linux hostAddr 2.6.16.60-0.34-smp #1 SMP Fri J         


        
相关标签:
11条回答
  • 2020-12-12 11:30

    Just an additional point about previous answers that cost me some minor time to figure out.
    When I used relative path in the policy file ${java.home}/lib/tools.jar it actually pointed jstatd to JAVA_HOME/jre/ directory and since I had jdk installed I had to use ${java.home}/../lib/tools.jar instead to get to the right place.

    EDIT I was running jstatd from within a docker container running ubuntu with jdk 8 (JAVA_HOME was set correctly).

    0 讨论(0)
  • 2020-12-12 11:35

    Just found following script to run jstatd. I managed to run jstatd with this script https://gist.github.com/nicerobot/1375032

    #!/bin/sh
    policy=${HOME}/.jstatd.all.policy
    [ -r ${policy} ] || cat >${policy} <<'POLICY'
    grant codebase "file:${java.home}/../lib/tools.jar" {
    permission java.security.AllPermission;
    };
    POLICY
    
    jstatd -J-Djava.security.policy=${policy} &
    
    0 讨论(0)
  • 2020-12-12 11:35

    I created new policy with following content:

    grant codebase "file:/usr/java/latest/lib/tools.jar" { permission java.security.AllPermission; };

    and then start jstatd with that policy with following command:

    jstatd -J-Djava.security.policy=/usr/java/jstatd.all.policy &

    0 讨论(0)
  • 2020-12-12 11:38

    Or you can use ejstatd instead of jstatd which automatically handles this problem: just run it using mvn exec:java inside ejstatd folder.

    Disclaimer: I'm the author of this open source tool.

    0 讨论(0)
  • 2020-12-12 11:41

    I have the same problem and that what you should do:

    1. Make sure that javac is in your $PATH
    2. Specify full (absolute) path to the policy file when running jstatd
      jstatd -J-Djava.security.policy=/path/to/jstatd.all.policy

    It helped for me.

    0 讨论(0)
提交回复
热议问题