[英]Applet runs fine in Eclipse; but running in Chrome gives InvocationTargetException
I have made a Swing applet which will run inside Eclipse with no problems, but when I run it with an html file using Chrome I get a runtime exception: java.lang.reflect.InvocationTargetException. 我制作了一个可以在Eclipse内正常运行的Swing小程序,但是当我使用Chrome使用html文件运行它时,出现运行时异常:java.lang.reflect.InvocationTargetException。 Can anyone suggest what is wrong please? 任何人都可以建议出什么问题了吗? Here is what I have tried: 这是我尝试过的:
I have read that InvocationTargetException wraps around some other error (a different error is causing it) but I do not know which method to put try{} catch(InvocationTargetException e){ e.toString()} around to get a useful error. 我已经读过InvocationTargetException会包装一些其他错误(导致它的是另一个错误),但是我不知道该使用哪种方法来尝试try {} catch(InvocationTargetException e){e.toString()}来获得有用的错误。
Online material suggest I have generate a stack trace using jdb, but again it does not seem to contain any useful information to find the cause of the exception: 在线材料建议我已经使用jdb生成了堆栈跟踪,但同样,它似乎不包含任何有用的信息来查找异常原因:
StackTrace 堆栈跟踪
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)
The problem was I was initialising variables outside of the init()
method. 问题是我正在初始化init()
方法之外的变量。 It seems that Eclipse does not have a problem with this but running it with a browsers Java Plug-In throws a java.lang.reflection.InterruptedThreadException
. 看来Eclipse对此没有问题,但是使用浏览器运行它Java Plug-In会抛出java.lang.reflection.InterruptedThreadException
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.