OpenMap-java / openmap

OpenMap is an Open Source JavaBeans-based programmer's toolkit. Using OpenMap, you can quickly build applications and applets that access data from legacy databases and applications.
http://openmap-java.org
Other
73 stars 43 forks source link

getJAI() fails with exception causing the application to crash #41

Open Scholvac opened 7 years ago

Scholvac commented 7 years ago

Hi,

I just stumbled over an exception inside the BufferedImageHelper, that causes my application to crash. I'm running in an plugin environment and are not able to load the JAI object, using the ComponentFactory (as indicated by the comments inside the ComponentFactory.create method). However switching the order of statements inside the BufferedImageHelper.getJAI() method solves the issue for me. Now I'm just getting one exception at the beginning and can use the fallback method you provided.

In my solution the BufferedImageHelper.getJAI() method looks like:

protected static Object getJAI() {
    if (!checkedForJAI) {
        checkedForJAI = true; //mark as checked before the exception occurs to not check again
        jaiObj = ComponentFactory.create("javax.media.jai.JAI");
    }
    return jaiObj;
}