• Post Reply Bookmark Topic Watch Topic
  • New Topic

Callback threw IllegalArgumentException error  RSS feed

 
Bill Denniston
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing an MIDP 2.0 MIDlet application in Neteans 6.5, using the Nokia S60 emulator. The MIDlet was created using the Visual MIDlet design feature of Netbeans. It's a simple form that accepts a numeric entry and plays an audio file.

The commandAction method created by Netbeans is where everything happens. When the "OK" command on the phone is invoked, a value is retrieved from a text field (key) and mapped to an audio file (value) in a Hashtable. This whole process is in a try - catch block that catches all the known exceptions to expect (including InvalidArgumentException), and it executes without exceptions when the entered value maps to a valid audio file. I test for an invalid key at the top of the try - catch block and bypass everything if it does not properly map. I expect that nothing should happen when an invalid entry is given, and no exception is trapped by the try - catch block.

However, when an entry is given that does not map to a valid audio file (i.e. Hashtable.get() returns null), the try - catch does not trap an exception, but an InvalidArgumentException is thrown by "Callback". I don't know what is throwing this exception. It is not happening in the commandAction try - catch which is substantively all there is in the method. No stack trace or other diagnostic is provided, just the notation on the command line that Callback threw the exception. The phone emulator also reports (embarassingly) to the user that an "Unhandled exception" has occurred and asks if the application (MIDlet) should be closed. (If the MIDlet is allowed to continue to execute, it takes the next entry just fine and either works like a champ or exhibits the same poor behavior again depending upon the validity of the entry.

Any ideas on where to hunt down the Callback exception would be appreciated. Thanks.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't there an emulator which you download with the Java ME? Can you run that from a command line and find the stack trace like that? If so, you can find where the Exception occurred.
I can't remember; it is several years since I had to use that emulator.

Does any of the methods you are calling declare an IllegalArgumentException in its documentation comments?
 
Bill Denniston
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm running the Nokia S60 emulator (have also run the stock emulators that come with WTK) and watch in the Netbeans output window what the command line gives as messages. That's where the "Callback threw exception" message appears. I'll check the docs on the Nokia emulator to see if I can intercept it another way. That's a good idea.

I catch the IllegalArgumentException in the try block, so I don't think its coming from anything I'm calling in my code...
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the stack trace say?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!