LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   X11 error with Java code on Red Hat (https://www.linuxquestions.org/questions/programming-9/x11-error-with-java-code-on-red-hat-273761/)

naijaguy 01-04-2005 12:18 PM

X11 error with Java code on Red Hat
 
I've Googled around, but I'm trying to figure out the right way to fix this. We have Java code that uses java.awt (Graphics2D stuff) to generate an image (which I've just read online could use some system-dependent stuff), and we've ported the code over to Linux, but now we're getting this error when our web app tries to generate the image:

Code:

javax.servlet.ServletException: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
        at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)

What's the best way to fix this? We're running just about the latest release, I think: Red Hat Enterprise Linux 3. Is there a quick and easy way to install something, or something even simpler, or what?

I Googled around some more, and then I went onto the app server as root and did the following:

#export DISPLAY=localhost:0.0
#xhost +
access control disabled, clients can connect from any host


I'm not sure if that fixed the problem. Now the error changed to the stuff down below, but I don't think it fixed it, because in my app logs I'm seeing NullPointerExceptions when trying to do stuff with the image:

Code:

javax.servlet.ServletException
        at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
        at org.apache.jsp.CreateShipment_jsp._jspService(CreateShipment_jsp.java:1197)


naijaguy 01-04-2005 04:38 PM

I added export CATALINA_OPTS=-Djava.awt.headless=true to /etc/profile and then I typed the following as root:

export DISPLAY=localhost:0.0
xhost +

Doing all of that worked on one Red Hat box, but on another machine that was recently installed from the same Red Hat CD, I'm getting this:

java.awt.HeadlessException
at sun.awt.HeadlessToolkit.getScreenResolution(HeadlessToolkit.java:184)
at com.idautomation.linear.BarCode.(com/idautomation/linear/BarCode)


I found this with Google:
http://www.idautomation.com/kb/jdk-1-4-error.html


I bought the upgrade and it works...still don't understand why it would work without the upgrade on one Enterprise Red Hat machine and not another. Oh well.

german 01-08-2005 05:23 PM

instead of spending more money you could have run XVFB as a virtual graphical environment, but then you'd have to have X installed... or you could have downloaded a newer, free JVM from http://java.sun.com/


All times are GMT -5. The time now is 07:30 AM.