I am running a servlet on jdk1.3 and Linux that displays a jpg image to
the web browser. The problem is, it only works when I logon to the
machine and restart tomcat (servlet engine). It does not work right
after a reboot, even though tomcat is being started automatically in
the runlevel. Everything else about tomcat works fine, following is
the error I get when trying to access the image. It is obviously
something to do with createGraphics(), but I am not displaying any
graphics, as you can see it is a BufferedImage,
Thanks in advance.
java.lang.InternalError: Can't connect to X11 window server
using 'localhost:0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.
(X11GraphicsEnvironment.java:58)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment
(GraphicsEnvironment.java:58)
at java.awt.image.BufferedImage.createGraphics
(BufferedImage.java:1011)
at com.im.image.ChartRenderer.createChart(ChartRenderer.java:68)
at com.im.servlets.image.PieChart.doGet(PieChart.java:33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest
(ServletWrapper.java:503)
at org.apache.tomcat.core.ServletWrapper.handleRequest
(ServletWrapper.java:597)
at org.apache.tomcat.servlets.InvokerServlet.service
(InvokerServlet.java:257)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest
(ServletWrapper.java:503)
at org.apache.tomcat.core.ContextManager.service
(ContextManager.java:559)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection
(HttpConnectionHandler.java:160)
at org.apache.tomcat.service.TcpConnectionThread.run
(SimpleTcpEndpoint.java:338)
at java.lang.Thread.run(Thread.java:484)
Sent via Deja.com
http://www.deja.com/
You should probably run xvfb and set an appropriate DISPLAY environment
variable in the shell that runs Tomcat. The problem is that Tomcat can't
access the X-server at the moment, which it needs to do for various
graphical things. This ("headless Java") is one of the things being
addressed in 1.4.
--
Jon Skeet - sk...@pobox.com
http://www.pobox.com/~skeet
Its a bug in the JDK -- see
http://developer.java.sun.com/developer/bugParade/bugs/4281163.html
They claim to have fixed it, but apparantly not. They say the only
workaround is to run an X Server and set your DISPLAY variable correctly.
Read it more carefully: it's fixed in a non-public release. Unless you
*have* a non-public release, you can't know whether or not it's actually
been fixed.
Why not? There are any number of good reasons why you may wish to create
graphics on the fly.
> when you create som Graphics, some AWT, or Swing Components on the server
> it ofcourse connects to the grapically display on the server. Which you
> shouldnt do....
> ..and which requires the X - server to be running.
Or requires Xvfb or a similar thing...
Of course, in 1.4 this will all change.
Why do you think you *shouldn't* dynamically generate graphics on a
server?