jps进程信息不可用 - jconsole和jvisualvm无法工作

18

在Windows系统更新后,我的jps、jconsole和jvisualvm都无法正常工作。

jps虽然能够给出进程ID,但却告诉我“进程信息不可用”。

而我无法像以前那样使用jvisualvm连接到这些进程。

我正在运行1.6.0_22 jre。

我以前已经遇到过类似的问题,尝试过这个技巧,并且它确实管用。但这次就倒霉了,它没有起作用。

编辑: 我找到了解决方法:在我的临时文件夹中,我删除了hsperfdata_<username>文件夹。显然,我的用户名大小写有问题。该文件夹名为hsperfdata_myname。在通过调用jps进行了销毁和重新创建之后,它被称为hasperfdata_MYNAME。

非常奇怪。

4个回答

27

在我的临时文件夹中,我删除了hsperfdata_文件夹。显然我的用户名的大小写有问题。该文件夹名字本应为hsperfdata_myname,但是经过jps调用的删除和重建后,名字变成了hasperfdata_MYNAME。

非常奇怪。


谢谢,谢谢,谢谢,谢谢……我都快把头发都拔光了。 - Philippe Girolami

10
在Unix上,确保你是以启动它的用户身份运行程序的。

2
不错!类似于:sudo -u用户名 jps - Lawrence Kesteloot
不错!我切换了用户,所有信息都可用。 - Reagan Ochora

0

我们这里也遇到了同样的问题。

临时文件夹的方法对我们也没有作用。

到目前为止,我们已经找到了几种方法来让事情重新正常:

  • 系统还原
  • 重命名“C:\Documents and Settings\myusername\Local Settings”下的临时文件夹并创建一个新的临时文件夹(关于Windows,我不确定这是否安全...)
  • 手动从临时文件夹中开始删除东西
  • 可能最安全的方法:运行ccleaner,它会清理临时文件夹

我最终找到了解决方案(请参见原问题)。 - Laurent K

0

我编写了一个脚本来应用这个解决方法,我从一些监控脚本中调用它,直到问题得到修复。

#!/bin/bash
# Name: fix_jps.bash
# Author: Cameron Pierce
#
# Purpose: create /tmp/hsperfdata directories that jps and jstat can work with

## VARIABLES
RETVAL=""
fileHSP=""
filePID=""
fileLOG=/tmp/fix_jps.log

# for every /tmp/hsperfdata_[name] directory that exists
for fileHSP in `ls -d /tmp/hsperfdata_*`; do
        #echo "entry ${fileHSP}" # DEBUG
        # if our search returns entries that are not directories, skip them
        if [ ! -d ${fileHSP} ]; then
                continue
        fi
        #ls ${fileHSP} # DEBUG

        # alternative to ls below
        #FINDFILES=(${fileHSP}/*)
        #if [ ${#FINDFILES[@]} -gt 0 ]; then
        #       echo "files in $fileHSP: ${#FINDFILES[@]} "
        #fi
    for filePID in `ls ${fileHSP}/ 2>> ${fileLOG} | grep "[[:digit:]]\{1,\}"`; do
            #echo "pid name: ${filePID}" # DEBUG
            # if the directory was empty, move on to the next fileENTRY
            if [ "${filePID}" == "" ]; then
                    #echo "the contents of the variable filePID appear to be empty \"${filePID}\"" # DEBUG
                    # remove the fileHSP if empty; this will clean up user hsperfdata dirs
                    rmdir ${fileHSP} 2>> ${fileLOG}
                    continue
            # if a symlink already exists, move on to the next fileENTRY
            elif [ -h /tmp/hsperfdata_${filePID} ]; then
                    #echo "symlink already exists for /tmp/hsperfdata_${filePID}" # DEBUG
                    continue
            fi
            #echo "name: ${filePID}"
            # if a process exists for filePID, create a symlink to the source file
            ps -eo pid | awk '{print $1}' | grep -q "^${filePID}$"
            RETVAL=$?
            # if a process exists with pid of filePID and a symlink doesn't exists, create symlink
            if [ $RETVAL -eq 0 -a ! -e /tmp/hsperfdata_${filePID} ]; then
                    ln -s ${fileHSP}/${filePID} /tmp/hsperfdata_$filePID
                    #echo ls -l /tmp/hs perfdata_${filePID} # DEBUG
            fi
    done
done

# remove broken symlinks
#find -L /tmp/hsperfdata_* -type l # DEBUG
find -L /tmp/hsperfdata_* -type l -delete

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接