NullPointerException in invokeLater while running through Java Webstart

I found what I believe to be a better solution to this bug.

I just added the following code before calling SwingUtilities or any Swing related component method. It create a new AppContext for the RMI Thread (RMI thread must be the current Thread when running the code below).

if(AppContext.getAppContext() == null){
    SunToolkit.createNewAppContext();
}

Due to the needs of my application I was able to add it on a single method that was using SwingUtilities, but you may need to add it to every method on your RMI Callable Object.

The code needs to run only once, so check the behavior of your application.

Leave a Comment