编辑:我的自定义处理程序中有一个静态初始化程序块。当我删除它运行正常。我怀疑静态初始化程序有问题。它尝试访问某些系统属性和一些LogManager属性。
我从Eclipse Kepler运行GlassFish。
我将自己的自定义记录器添加到GlassFish 4,如Administration guide
第7章所述我所做的就是将新的Handler jar放入domain-dir/lib/ext
目录并在logging.properties
文件中引用它:
处理器= java.util.logging.ConsoleHandler,com.mytools.logging.JMSFileHandler
但是,当我启动GlassFish时,它会挂起69%,过了一段时间我会收到超时错误:
java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(Unknown Source)
at oracle.eclipse.tools.glassfish.GlassfishGenericServerBehaviour.launchServer(GlassfishGenericServerBehaviour.java:202)
at oracle.eclipse.tools.glassfish.GlassfishServerLaunchDelegate.startDASAndTarget(GlassfishServerLaunchDelegate.java:206)
at oracle.eclipse.tools.glassfish.GlassfishServerLaunchDelegate.launch(GlassfishServerLaunchDelegate.java:110)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:858)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:707)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:700)
at org.eclipse.wst.server.core.internal.Server.startImpl2(Server.java:3537)
at org.eclipse.wst.server.core.internal.Server.startImpl(Server.java:3473)
at org.eclipse.wst.server.core.internal.Server$StartJob.run(Server.java:367)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
VisualVM Threaddump:
2014-08-19 17:50:19
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.25-b01 mixed mode):
"FelixFrameworkWiring" daemon prio=6 tid=0x000000000d95a800 nid=0x2a0c in Object.wait() [0x00000000110bf000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e14d0148> (a java.util.ArrayList)
at java.lang.Object.wait(Object.java:503)
at org.apache.felix.framework.FrameworkWiringImpl.run(FrameworkWiringImpl.java:162)
- locked <0x00000000e14d0148> (a java.util.ArrayList)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"deployment-jar-scanner" daemon prio=6 tid=0x000000000d959800 nid=0x2f00 waiting on condition [0x0000000010f2e000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"deployment-jar-scanner" daemon prio=6 tid=0x000000000d959000 nid=0x27c waiting on condition [0x0000000010d5f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"deployment-jar-scanner" daemon prio=6 tid=0x000000000d957800 nid=0x1c78 waiting on condition [0x000000001278e000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"deployment-jar-scanner" daemon prio=6 tid=0x000000000d956800 nid=0x3344 waiting on condition [0x00000000115ce000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"deployment-jar-scanner" daemon prio=6 tid=0x000000000d956000 nid=0x2898 waiting on condition [0x0000000010bee000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"transaction-manager" daemon prio=6 tid=0x000000000d953000 nid=0x3320 in Object.wait() [0x00000000107ff000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e1eb8be8> (a java.util.TaskQueue)
at java.lang.Object.wait(Object.java:503)
at java.util.TimerThread.mainLoop(Timer.java:526)
- locked <0x00000000e1eb8be8> (a java.util.TaskQueue)
at java.util.TimerThread.run(Timer.java:505)
Locked ownable synchronizers:
- None
"Thread-11" daemon prio=6 tid=0x000000000d952000 nid=0x1f7c waiting on condition [0x000000001013e000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e20a48b8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:374)
at com.sun.enterprise.server.logging.GFFileHandler.log(GFFileHandler.java:825)
at com.sun.enterprise.server.logging.GFFileHandler$3.run(GFFileHandler.java:540)
Locked ownable synchronizers:
- None
"deployment-jar-scanner" daemon prio=6 tid=0x000000000d951800 nid=0x29c8 waiting on condition [0x00000000106af000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"deployment-jar-scanner" daemon prio=6 tid=0x000000000d950800 nid=0x21e0 waiting on condition [0x00000000104ef000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"deployment-jar-scanner" daemon prio=6 tid=0x000000000d950000 nid=0x1e84 waiting on condition [0x000000000fd9e000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"pool-3-thread-1" prio=6 tid=0x000000000d94e800 nid=0x2a98 waiting on condition [0x000000001036f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1f56a88> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"SCR Component Actor" daemon prio=6 tid=0x000000000d82d000 nid=0x234 in Object.wait() [0x000000000ffee000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e1fa3df0> (a java.util.LinkedList)
at java.lang.Object.wait(Object.java:503)
at org.apache.felix.scr.impl.ComponentActorThread.run(ComponentActorThread.java:74)
- locked <0x00000000e1fa3df0> (a java.util.LinkedList)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"fileinstall-C:\Work\issue\issRepo\tap-server\server\glassfish\domains\domain1/autodeploy/bundles/plugins/" daemon prio=6 tid=0x000000000da94000 nid=0x30cc in Object.wait() [0x000000000b69e000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e1fb4648> (a org.apache.felix.fileinstall.internal.DirectoryWatcher)
at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:268)
- locked <0x00000000e1fb4648> (a org.apache.felix.fileinstall.internal.DirectoryWatcher)
Locked ownable synchronizers:
- None
"Configuration Updater" daemon prio=6 tid=0x000000000d3a7800 nid=0x838 in Object.wait() [0x000000000fbef000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e1fe1078> (a java.util.LinkedList)
at java.lang.Object.wait(Object.java:503)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:67)
- locked <0x00000000e1fe1078> (a java.util.LinkedList)
Locked ownable synchronizers:
- None
"DestroyJavaVM" prio=6 tid=0x000000000239c000 nid=0x35ac waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"GlassFish Kernel Main Thread" prio=6 tid=0x000000000cdbb800 nid=0x3498 in Object.wait() [0x000000000fa2f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e2094990> (a com.sun.enterprise.v3.server.AppServerStartup$1)
at java.lang.Object.wait(Object.java:503)
at com.sun.enterprise.v3.server.AppServerStartup$1.run(AppServerStartup.java:245)
- locked <0x00000000e2094990> (a com.sun.enterprise.v3.server.AppServerStartup$1)
Locked ownable synchronizers:
- None
"pool-1-thread-1" daemon prio=6 tid=0x000000000c9aa800 nid=0x908 waiting on condition [0x000000000f78e000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000e1b99be0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"FelixStartLevel" daemon prio=6 tid=0x000000000c7d5800 nid=0x32e8 in Object.wait() [0x000000000c39f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e14cfed8> (a java.util.ArrayList)
at java.lang.Object.wait(Object.java:503)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:279)
- locked <0x00000000e14cfed8> (a java.util.ArrayList)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"FelixDispatchQueue" daemon prio=6 tid=0x000000000a74f800 nid=0x3644 in Object.wait() [0x000000000c66e000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e14f7828> (a java.util.ArrayList)
at java.lang.Object.wait(Object.java:503)
at org.apache.felix.framework.util.EventDispatcher.run(EventDispatcher.java:1063)
- locked <0x00000000e14f7828> (a java.util.ArrayList)
at org.apache.felix.framework.util.EventDispatcher.access$000(EventDispatcher.java:54)
at org.apache.felix.framework.util.EventDispatcher$1.run(EventDispatcher.java:101)
at java.lang.Thread.run(Thread.java:724)
Locked ownable synchronizers:
- None
"Service Thread" daemon prio=6 tid=0x000000000a489800 nid=0x3464 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"C2 CompilerThread1" daemon prio=10 tid=0x000000000a489000 nid=0x35a0 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"C2 CompilerThread0" daemon prio=10 tid=0x000000000a484000 nid=0x34ec waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"JDWP Event Helper Thread" daemon prio=6 tid=0x000000000a476000 nid=0x2de4 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"JDWP Transport Listener: dt_socket" daemon prio=6 tid=0x000000000a472800 nid=0x20f0 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Attach Listener" daemon prio=10 tid=0x000000000a3d3000 nid=0x2f78 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Signal Dispatcher" daemon prio=10 tid=0x000000000a3d2000 nid=0x238 runnable [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Finalizer" daemon prio=8 tid=0x0000000008341800 nid=0x3584 in Object.wait() [0x000000000a27f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e092a1e8> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
- locked <0x00000000e092a1e8> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:189)
Locked ownable synchronizers:
- None
"Reference Handler" daemon prio=10 tid=0x0000000008337800 nid=0x2258 in Object.wait() [0x000000000a37f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e0929ca8> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
- locked <0x00000000e0929ca8> (a java.lang.ref.Reference$Lock)
Locked ownable synchronizers:
- None
"VM Thread" prio=10 tid=0x0000000008330000 nid=0x1fd0 runnable
"GC task thread#0 (ParallelGC)" prio=6 tid=0x00000000023ad000 nid=0x37b8 runnable
"GC task thread#1 (ParallelGC)" prio=6 tid=0x00000000023af000 nid=0x1a98 runnable
"GC task thread#2 (ParallelGC)" prio=6 tid=0x00000000023b1800 nid=0x34fc runnable
"GC task thread#3 (ParallelGC)" prio=6 tid=0x00000000023b3000 nid=0x3368 runnable
"GC task thread#4 (ParallelGC)" prio=6 tid=0x00000000023b6800 nid=0x2844 runnable
"GC task thread#5 (ParallelGC)" prio=6 tid=0x00000000023b8000 nid=0xde4 runnable
"GC task thread#6 (ParallelGC)" prio=6 tid=0x00000000023b9000 nid=0x2ba0 runnable
"GC task thread#7 (ParallelGC)" prio=6 tid=0x00000000023bc800 nid=0x2c98 runnable
"VM Periodic Task Thread" prio=10 tid=0x000000000a49e800 nid=0x167c waiting on condition
JNI global references: 3733
答案 0 :(得分:1)
尝试使用详细的类加载输出运行。如果静态块中存在错误,该错误应显示为无法加载该类。
然后尝试以下方法之一:
如果可以的话,尝试摆脱静态块,只需获取构造属性。大多数处理程序都以这种方式工作,因此子类具有自己的logging.properties命名空间。
package baz;
import java.io.IOException;
import java.util.logging.FileHandler;
public class FooHandler extends FileHandler {
FooHandler() throws IOException {
super();
}
}
将inherit所有FileHandler属性:
baz.FooHandler.pattern=test.log
baz.FooHandler.append=true
您也可以尝试将该代码移动到嵌套类。
public class FooHandler extends Handler {
@Override
public void publish(LogRecord record) {
if ("baz".equals(Helper.logProperties.get("bar"))) {
}
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
if ("baz".equals(Helper.logProperties.get("foo"))) {
}
}
/**
* Private lazy loaded class.
*/
private static class Helper {
/**
* Use default access to avoid synthetic methods.
*/
static Properties logProperties = new Properties();
static {
try (InputStream packageStream = Helper.class.getResourceAsStream("JMSFileHandler.properties")) {
if (packageStream != null) {
logProperties.load(packageStream);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
请记住,默认的LogManager有一些类加载和死锁问题:
答案 1 :(得分:1)
经过大量的反复试验后,我发现问题出在我的处理程序类的静态初始化程序中。
有两个部分会冻结GlassFish并导致TimeoutException:
LogManager logManager = LogManager.getLogManager();
请记住,Jar文件将放在domain-dir/lib/ext
目录中:
Properties logProperties = new Properties();
try (InputStream packageStream = JMSFileHandler.class.getResourceAsStream("JMSFileHandler.properties")) {
if (packageStream != null) {
logProperties.load(packageStream); //this line causes freeze
}
} catch (IOException e) {
e.printStackTrace();
}
这里的关键线是标有//this line causes freeze
的线。所以它只是尝试加载导致问题的属性。
答案 2 :(得分:1)
我发现了问题。前两个导致GlassFish根本不显示任何日志消息并最终超时。最后一个只会导致处理程序死亡,而不会暗示为什么会发生这种情况。
我的自定义处理程序继承自java.util.logging.FileHandler
,正在阅读int
属性,例如&#39; limit&#39;。我认为我可以使用_
的Java约定作为数字分隔符。唉,这会在我的处理程序Integer.parseInt()
中抛出异常。
如果值为null,同样在我的处理程序Properties.setProperty(key, value)
中将抛出NullPointerException
。这不会直接记录在Properties
课程中,您必须在HashTable
(Properties
扩展)的文档中查找。
java.util.logging.FileHandler
读取名为&#39; pattern&#39;它指定日志文件。如果你指定一个不存在的目录,它将不会被创建,而是抛出异常,导致FileHandler
安静地死亡。
我仍然是GlassFish的问题,当自定义处理程序抛出异常GF应该能够从中恢复。也许那是因为它发生在静态初始化器中。