1

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. 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.

  • 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:

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)
Anthony Accioly
  • 21,918
  • 9
  • 70
  • 118
  • Do your code use any kind of reflection (especially [Method.invoke](http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object%2C%20java.lang.Object...)) or [Constructor.newInstance](http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Constructor.html#newInstance(java.lang.Object...)))? – Anthony Accioly Aug 02 '12 at 22:05
  • I don't explicitly use either Method.invoke or Constructor.newInstance. And I had never heard of reflection until this error showed up. – user1572503 Aug 02 '12 at 22:31

1 Answers1

0

The problem was I was initialising variables outside of the init() method. 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.

SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105