• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Callback threw IllegalArgumentException error

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does the stack trace say?
 
Space pants. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic