1

我制作了一个 Swing 小程序,它可以在 Eclipse 中毫无问题地运行,但是当我使用 Chrome 使用 html 文件运行它时,我得到一个运行时异常:java.lang.reflect.InvocationTargetException。任何人都可以建议有什么问题吗?这是我尝试过的:

  • 我已经读过 InvocationTargetException 包含了一些其他错误(导致它的另一个错误),但我不知道使用哪种方法来获取有用的错误 try{} catch(InvocationTargetException e){ e.toString()}。

  • 在线材料建议我使用 jdb 生成堆栈跟踪,但它似乎没有包含任何有用的信息来查找异常的原因:

堆栈跟踪

TimerQueue:
  [1] sun.misc.Unsafe.park (native method)
  [2] java.util.concurrent.locks.LockSupport.park (null)
  [3] java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awai
t (null)
  [4] java.util.concurrent.DelayQueue.take (null)
  [5] javax.swing.TimerQueue.run (null)
  [6] java.lang.Thread.run (null)
ConsoleTraceListener:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:503)
  [3] com.sun.deploy.uitoolkit.ui.ConsoleTraceListener$ConsoleWriterThread.run (
null)
TimerQueue:
  [1] sun.misc.Unsafe.park (native method)
  [2] java.util.concurrent.locks.LockSupport.park (null)
  [3] java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awai
t (null)
  [4] java.util.concurrent.DelayQueue.take (null)
  [5] javax.swing.TimerQueue.run (null)
  [6] java.lang.Thread.run (null)
D3D Screen Updater:
  [1] java.lang.Object.wait (native method)
  [2] sun.java2d.d3d.D3DScreenUpdateManager.run (null)
  [3] java.lang.Thread.run (null)
AWT-EventQueue-1:
  [1] sun.misc.Unsafe.park (native method)
  [2] java.util.concurrent.locks.LockSupport.park (null)
  [3] java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awai
t (null)
  [4] java.awt.EventQueue.getNextEvent (null)
  [5] java.awt.EventDispatchThread.pumpOneEventForFilters (null)
  [6] java.awt.EventDispatchThread.pumpEventsForFilter (null)
  [7] java.awt.EventDispatchThread.pumpEventsForHierarchy (null)
  [8] java.awt.EventDispatchThread.pumpEvents (null)
  [9] java.awt.EventDispatchThread.pumpEvents (null)
  [10] java.awt.EventDispatchThread.run (null)
AWT-EventQueue-2:
  [1] sun.misc.Unsafe.park (native method)
  [2] java.util.concurrent.locks.LockSupport.park (null)
  [3] java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awai
t (null)
  [4] java.awt.EventQueue.getNextEvent (null)
  [5] java.awt.EventDispatchThread.pumpOneEventForFilters (null)
  [6] java.awt.EventDispatchThread.pumpEventsForFilter (null)
  [7] java.awt.EventDispatchThread.pumpEventsForHierarchy (null)
  [8] java.awt.EventDispatchThread.pumpEvents (null)
  [9] java.awt.EventDispatchThread.pumpEvents (null)
  [10] java.awt.EventDispatchThread.run (null)
Applet 3 LiveConnect Worker Thread:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:503)
  [3] sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$LiveConnectWorker
.run (null)
  [4] java.lang.Thread.run (null)
Browser Side Object Cleanup Thread:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.ref.ReferenceQueue.remove (null)
  [3] java.lang.ref.ReferenceQueue.remove (null)
  [4] sun.plugin2.main.client.LiveConnectSupport$BrowserSideObjectCleanupThread.
run (null)
CacheCleanUpThread:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:503)
  [3] com.sun.deploy.cache.CleanupThread.run (null)
CacheMemoryCleanUpThread:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.ref.ReferenceQueue.remove (null)
  [3] java.lang.ref.ReferenceQueue.remove (null)
  [4] com.sun.deploy.cache.MemoryCache$LoadedResourceCleanupThread.run (null)
SysExecutionTheadCreator:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:503)
  [3] sun.plugin.util.PluginSysUtil$SysExecutionThreadCreator.run (null)
AWT-EventQueue-0:
  [1] sun.misc.Unsafe.park (native method)
  [2] java.util.concurrent.locks.LockSupport.park (null)
  [3] java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awai
t (null)
  [4] java.awt.EventQueue.getNextEvent (null)
  [5] java.awt.EventDispatchThread.pumpOneEventForFilters (null)
  [6] java.awt.EventDispatchThread.pumpEventsForFilter (null)
  [7] java.awt.EventDispatchThread.pumpEventsForHierarchy (null)
  [8] java.awt.EventDispatchThread.pumpEvents (null)
  [9] java.awt.EventDispatchThread.pumpEvents (null)
  [10] java.awt.EventDispatchThread.run (null)
AWT-Windows:
  [1] sun.awt.windows.WToolkit.eventLoop (native method)
  [2] sun.awt.windows.WToolkit.run (null)
AWT-Shutdown:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:503)
  [3] sun.awt.AWTAutoShutdown.run (null)
  [4] java.lang.Thread.run (null)
Java2D Disposer:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.ref.ReferenceQueue.remove (null)
  [3] java.lang.ref.ReferenceQueue.remove (null)
  [4] sun.java2d.Disposer.run (null)
  [5] java.lang.Thread.run (null)
Java Plug-In Pipe Worker Thread (Client-Side):
  [1] sun.plugin2.os.windows.Windows.ReadFile0 (native method)
  [2] sun.plugin2.os.windows.Windows.ReadFile (null)
  [3] sun.plugin2.ipc.windows.WindowsNamedPipe.read (null)
  [4] sun.plugin2.message.transport.NamedPipeTransport$SerializerImpl.read (null
)
  [5] sun.plugin2.message.transport.NamedPipeTransport$SerializerImpl.readByte (
null)
  [6] sun.plugin2.message.AbstractSerializer.readInt (null)
  [7] sun.plugin2.message.transport.SerializingTransport.read (null)
  [8] sun.plugin2.message.Pipe$WorkerThread.run (null)
Timer-0:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:503)
  [3] java.util.TimerThread.mainLoop (null)
  [4] java.util.TimerThread.run (null)
traceMsgQueueThread:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:503)
  [3] com.sun.deploy.trace.Trace$TraceMsgQueueChecker.run (null)
  [4] java.lang.Thread.run (null)
Attach Listener:
Signal Dispatcher:
Finalizer:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.ref.ReferenceQueue.remove (null)
  [3] java.lang.ref.ReferenceQueue.remove (null)
  [4] java.lang.ref.Finalizer$FinalizerThread.run (null)
Reference Handler:
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:503)
  [3] java.lang.ref.Reference$ReferenceHandler.run (null)
main:
  [1] java.lang.Object.wait (native method)
  [2] sun.plugin2.message.Queue.waitForMessage (null)
  [3] sun.plugin2.message.Pipe$1.run (null)
  [4] com.sun.deploy.util.Waiter$1.wait (null)
  [5] com.sun.deploy.util.Waiter.runAndWait (null)
  [6] sun.plugin2.message.Pipe.receive (null)
  [7] sun.plugin2.main.client.PluginMain.mainLoop (null)
  [8] sun.plugin2.main.client.PluginMain.run (null)
  [9] sun.plugin2.main.client.PluginMain.main (null)
4

1 回答 1

0

问题是我在init()方法之外初始化变量。Eclipse 似乎对此没有问题,但使用浏览器Java 插件运行它会抛出java.lang.reflection.InterruptedThreadException.

于 2012-08-03T07:09:25.077 回答