tags:

views:

619

answers:

6

I am trying to debug a problem where a user clicks on the button and the UI just dies. I know, good luck.

The logs just end after the user clicks the button so i'm thinking there may be some exception/error that we are not logging. Maybe an OutOfMemoryError.

Any suggestions on how to proceed? to get more information. Java command setting etc.

Thanks for any help

  • rich
A: 

Try redirecting standard output - you'll probably see the exception stack trace there.

Paul Tomblin
A: 

You must have an event listener waiting for the mouse clicked event. Did you trace through that code to a specific line?

The code must at least reach the first line, I can't see the event listener not working.

You'll need to break it down a bit.

And if it's only got one line, then you need to drill into that code until you have more than one line, or until you can isolate it some more...

Stephane Grenier
+3  A: 

Which version of java and what machine?

In any case, here's the scoop: the event queue thread runs somewhat separately from the main thread. In Java < 5 there was a bug that made it difficult to capture events from that thread, so some exceptions just went away. In Java 5, there's a new method Thread.setDefaultUncaughtExceptionHandler() that will let you set up an exception handler for anything that might otherwise have gone uncaught. Add a handler there, and catch all Throwables and log them.

This is also a good hack for dealing with things you might otherwise call System.exit() for, as well; have a normalExit Throwable; throw that anywhere you'd call exit in the GUI, and make sure all gets cleaned up.

Charlie Martin
Charlie: I think of myself as pretty Java savant and this is one new feature of the language I definitely didn't know about. Thanks for sharing it!
Stephane Grenier
Well, it happened in part because I complained about the difficulty when I was a Java Architect at Sun. System.exit() basically just shoots the process in the head; I wanted an orderly shutdown.
Charlie Martin
A: 

I don't know what you mean by "just dies".

  • Does the UI still redraw itself if you drag it outside your screen edge and then back in?
  • Does the entire process eventually terminate unexpectedly?
  • Does the entire process immediately terminate unexpectedly?

Assuming the UI is still there when you click a button, and nothing seems to be happening, another easy way to diagnose what might be going wrong is to monitor that process' CPU and memory usage. Task Manager (or better, Process Explorer) if you're in Windows; ps if you're some flavor of Unix (and probably Mac as well). Check how much CPU that process is using first.

If it's 0%, then you probably have something benign, like the button having no listener (and hence clicking it has no effect whatsoever).

If it's 100%, then you probably have some business logic running like mad, possibly in an infinite loop. Two things to look at: one, check memory usage, and see whether it's going up; a bug could be causing large numbers of objects to be created, and you'll eventually run out of memory. It's impossible to say for sure without knowing what the code does. The second thing is mentioned above: drag the UI offscreen and then back. Java's EDT (Event Dispatch Thread) is responsible for handling all UI events, including redrawing the UI when it is made visible; if it doesn't do that, then you know something is running in the EDT that shouldn't be, keeping it from getting around to doing things like redraws. For all I know, the business logic is working just fine, but merely takes a while, and is hogging the EDT.

(If it's just under 50%, 33%, 25%, etc., then you're on a multiple-CPU machine; see 100% above...)

From your description, however (namely, "the logs just end"), it sounds like your UI or business logic is waiting on something that'll never come, so you'll have 0% CPU on that process. Worth checking anyway, since it's quick and can head off a needless bug hunt in the wrong place.

Paul Brinkley
A: 

the application is running on java 1.6. and the entire process immediately terminate unexpectedly.

One other piece of information is that the swing app is started using webstart.

i'm are looking through code, based on the last line in the log, to see if i can figure out what's happening.

unfortunately this has happened before and each time at a different point, so i haven't been able to reproduce.

we'll probably end up eventually using the Thread.setDefaultUncaughtExceptionHandler() suggestion and see if we can get more info.

any more thought are welcome. thanks so much for the help

richs
A: 

i was able to find the jvm error file.
Looks like something happened while in the "AWT-Windows" native thread.

=>0x02acf000 JavaThread "AWT-Windows" daemon [_thread_in_native, id=3616, stack(0x02eb0000,0x02f00000)]

siginfo: ExceptionCode=0xc0000005, writing address 0xe2789280

Registers: EAX=0x234f099c, EBX=0x00001400, ECX=0x00000100, EDX=0xe2789280 ESP=0x02eff4a4, EBP=0x00000400, ESI=0x234f099c, EDI=0xe2789280 EIP=0x6d02bcbd, EFLAGS=0x00010206

Top of Stack: (sp=0x02eff4a4) 0x02eff4a4: 02eff500 00000100 02eff584 00000100
0x02eff4b4: 6d0a5697 00000400 00000400 00000100
0x02eff4c4: 00000100 02eff700 02eff500 00000000
0x02eff4d4: 00000000 00000100 041ac3a0 00000100
0x02eff4e4: 00182620 00000400 e2789280 00000000
0x02eff4f4: 00000000 00000100 00000100 00000000
0x02eff504: 00000000 00000100 00000100 00000000
0x02eff514: 00000000 00000004 00000400 00000000

Instructions: (pc=0x6d02bcbd)
0x6d02bcad: 00 00 00 8b 4c 24 14 8b e9 c1 e9 02 8b f0 8b fa
0x6d02bcbd: f3 a5 8b cd 83 e1 03 f3 a4 8b 74 24 18 8b 4c 24

Stack: [0x02eb0000,0x02f00000], sp=0x02eff4a4, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [awt.dll+0x2bcbd]

[error occurred during error reporting (printing native stack), id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j sun.awt.windows.WToolkit.eventLoop()V+0
j sun.awt.windows.WToolkit.run()V+69
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub

richs