Thursday, February 12, 2009

Some trouble with AWT libraries on Linux

Our application is fine, thanks for asking. Our painfull security problem is gone, which will probably be the topic of next posto. But here is the fresh problem and a fresh solution.


Our app is using some fancy graph solutions for displaying some statistical data form the application. We are using some ADF stuff, there are some cute controls to help you with that. We are developing on Windows, so the test servers were there. So, today is the big day when I am setting up some VMs for live testing and we are using Linux on them. WLS is installed, domain configured (actually, I just copied domain folder from Windows to Linux and changed paths etc. also an interesting topic) . Server started, I go to a login page, log in, I get main window whith menus and wait for my graphs to be rendered... And the, exception printed on the console, my session breaks and I am returned to the login page!

Here are the interesting parts from stacktrace:

SEVERE: Server Exception during PPR, #1
javax.servlet.ServletException: java.lang.InternalError: Can't connect to X11 window server using 'centosbi.antegra.com:99' as the value of the DISPLAY variable

java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment

X11? WTF?


Google is my best friend, so I came up with some pointers quite fast:

link1

So, it turns out that if I use something from AWT, I need X environment. No way! Well, the guys suggested xvfb solution, which didnt make me very happy... But some guy suggested to set java parameter

-Djava.awt.headless=true

So I tried that. I set it into setDomainEnv.sh file like java property in line JAVA_OPTIONS=...


And it worked.


So, if you use Oracle graphical components for rendering bars, pie charts etc. on Linux, you better set this parameter.

Cheers!

2 comments:

  1. is there any other way to solve this problem with out setting DISPLAY variable.

    thank you.

    ReplyDelete