Skip to main content

BlackBerry IllegalArgumentException when returning to app

3 replies [Last post]
wilmarvh
Offline
Joined: 2010-02-10

Hi there

I have ported a J2ME app to BlackBerry, 90% of it went pretty smooth with only minor adjustments required here and there. I have however noticed some random behaviour on the BlackBerry 9500 (only model tested on so far).

To reproduce the error:
- Open my application (basically a modifed version of the LWUIT demo app)
- Press the Call Button on the handset (green button)
- Press the Back button
- Upon returning to my application a LWUIT dialog pops up stating that there is an IllegalArgumentException. The exact wording of the errors is:

Error - An internal application error occured: java.lang.IllegalArgumentException: Component is already contained in Container: (insert lots or weird variables here)

Now it looks like the framework is trying to repaint or something the screen when it gets focus. What eventually happens on another screen is the exception occurs and then the main screen is empty with only the logo displaying.

Any ideas on how to fix this, or at least not show the dialogs? The application doesn't crash or anything as yet, but it is quite annoying.

Kind regards

Wilmar

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07

Open the device log (for storm you need a special app to access the log) and extract a stack trace from the log.

wilmarvh
Offline
Joined: 2010-02-10

Found the problem.

LWUIT was trying to re-append some components for a second time, gave a massive exception. A simple null check solved it.

Arnau Vazquez

Hi,

I guess you are having some threading issue, or some method is being called
twice (onShow(), etc) and you are doing some addComponent() operation twice.
Put logs and/or debug to see which one that is. Then solve that or use
Container.contains() to handle the case and avoid the exception.
If you don't want the exception to show, extend BBScreenImplementation and
override handleEDTException().

Greetings,
Arnau

2010/2/10

> Hi there
>
> I have ported a J2ME app to BlackBerry, 90% of it went pretty smooth with
> only minor adjustments required here and there. I have however noticed some
> random behaviour on the BlackBerry 9500 (only model tested on so far).
>
> To reproduce the error:
> - Open my application (basically a modifed version of the LWUIT demo app)
> - Press the Call Button on the handset (green button)
> - Press the Back button
> - Upon returning to my application a LWUIT dialog pops up stating that
> there is an IllegalArgumentException. The exact wording of the errors is:
>
> Error - An internal application error occured:
> java.lang.IllegalArgumentException: Component is already contained in
> Container: (insert lots or weird variables here)
>
> Now it looks like the framework is trying to repaint or something the
> screen when it gets focus. What eventually happens on another screen is the
> exception occurs and then the main screen is empty with only the logo
> displaying.
>
> Any ideas on how to fix this, or at least not show the dialogs? The
> application doesn't crash or anything as yet, but it is quite annoying.
>
> Kind regards
>
> Wilmar
> [Message sent by forum member 'wilmarvh' (wilmarvh@netstar.altech.co.za)]
>
> http://forums.java.net/jive/thread.jspa?messageID=385828
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
[att1.html]