java.lang.Thread.State:等待(在对象监视器上)

java.lang.Thread.State: WAITING (on object monitor)

我正在尝试使用 python 卡在文件处理程序中的代码创建 weblogic 域,下面是代码和堆栈跟踪,它们正在等待您能帮忙修复它吗?

import os
import sys
import wl as myWLST

from java.lang import System,Runtime,Process,String
from java.io import BufferedReader,InputStreamReader,File
from java.util.logging import FileHandler,Logger,SimpleFormatter

from com.oracle.cie.domain.script.jython import WLSTException
from com.oracle.cie.domain.script import ScriptException
from WeblogicConfigXmlParser import XmlParser

#=====================
# Program starts here
#=====================
if __name__ == "__main__":
    print "in main"
    print len(sys.argv)
    if len(sys.argv) < 2:
                print 'Insufficent arguments'
                System.exit(-1)
    else:
        try:
            print "inside try - JASON"
            print (os.getcwd())
            fileHandler = FileHandler("weblogic.log",1);
            print "inside try 2"
            fileHandler.setFormatter(SimpleFormatter());`

卡在第"fileHandler = FileHandler("weblogic.log",1);",

堆栈跟踪:

Full thread dump Java HotSpot(TM) Server VM (24.255-b255-jre1.7.0.25.ia-rc1 mixed mode):

"Attach Listener" daemon prio=8 tid=0x00835000 nid=13 lwp_id=3559300 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Service Thread" daemon prio=8 tid=0x00676c00 nid=12 lwp_id=3559264 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=8 tid=0x00670600 nid=10 lwp_id=3559262 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=8 tid=0x0066ce00 nid=9 lwp_id=3559261 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=8 tid=0x0066aa00 nid=8 lwp_id=3559260 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x00653a00 nid=7 lwp_id=3559259 in Object.wait() [0x484c0000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x73a28788> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:152)
    - locked <0x73a28788> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:168)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:248)

"Reference Handler" daemon prio=8 tid=0x00651600 nid=6 lwp_id=3559258 in Object.wait() [0x4a3c0000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x73a28818> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:140)
    - locked <0x73a28818> (a java.lang.ref.Reference$Lock)

"main" prio=8 tid=0x00473400 nid=1 lwp_id=-1 runnable [0x7fffd000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.ch.FileDispatcherImpl.lock0(Native Method)
    at sun.nio.ch.FileDispatcherImpl.lock(FileDispatcherImpl.java:90)
    at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1098)
    at java.nio.channels.FileChannel.tryLock(FileChannel.java:1154)
    at java.util.logging.FileHandler.openFiles(FileHandler.java:438)
    - locked <0x710b6228> (a java.util.HashMap)
    at java.util.logging.FileHandler.<init>(FileHandler.java:310)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.python.core.PyReflectedConstructor.__call__(Unknown Source)
    at org.python.core.PyJavaInstance.__init__(Unknown Source)
    at org.python.core.PyJavaClass.__call__(Unknown Source)
    at org.python.core.PyObject.__call__(Unknown Source)
    at org.python.pycode._pyx0.f[=12=](/SHARED/scripts/weblogicscripts/WeblogicDomainManager.py:428)
    at org.python.pycode._pyx0.call_function(/SHARED/scripts/weblogicscripts/WeblogicDomainManager.py)
    at org.python.core.PyTableCode.call(Unknown Source)
    at org.python.core.PyCode.call(Unknown Source)
    at org.python.core.Py.runCode(Unknown Source)
    at org.python.core.__builtin__.execfile_flags(Unknown Source)
    at org.python.util.PythonInterpreter.execfile(Unknown Source)
    at org.python.util.jython.main(Unknown Source)

"VM Thread" prio=8 tid=0x00640400 nid=5 lwp_id=3559257 runnable 

"GC task thread#0 (ParallelGC)" prio=8 tid=0x00495000 nid=3 lwp_id=3559255 runnable 

"GC task thread#1 (ParallelGC)" prio=8 tid=0x004bb600 nid=4 lwp_id=3559256 runnable 

"VM Periodic Task Thread" prio=8 tid=0x00674800 nid=11 lwp_id=3559263 waiting on condition 

JNI global references: 273

无法弄清楚为什么它卡在文件处理程序上,它正在创建任何 weblogic.log 并且没有超时。即使我基于此 post object waiting 使用了“-XX:CompileCommand="exclude,java/lang/Object.wait" 但仍然没有运气。

将日志文件的位置从 /SHARED 更改为本地后即可解决

旧:

 fileHandler = FileHandler("/SHARED/weblogic.log",1);
                print "inside try 2"
                fileHandler.setFormatter(SimpleFormatter());`

新:

 fileHandler = FileHandler("/home/user/weblogic.log",1);
            print "inside try 2"
            fileHandler.setFormatter(SimpleFormatter());`

文件系统,写入文件时 /shared 文件系统出现一些问题,这就是卡住的原因。