IDependOn-Set: 1
IDependOn-Set: 2
IDependOn-Set: 7
IDependOn-Set: 72
IDependOn-Set: 73
IDependOn-Set: 76
LastModifiedSecs: 938641938
Parent: 7
SequenceNumber: 5
Title: Setting the X11 DISPLAY
Part: 0
Author-Set: jon@working-dogs.com
HideAttributions: 1
LastModifiedSecs: 922323900
Type: monospaced
Lines: 67

----------
From: Shaoping Zhou <sxz@MetaphaseTech.com>
To: Java Apache Users <java-apache-users@list.working-dogs.com>
Subject: Re: setting the X11 windows DISPLAY
Date: Wed, Mar 24, 1999, 7:25 AM


I had the same problem earlier.  I guess that the root of the problem is that,
if you autostart JServ from Apache, then env var DISPLAY will not be handed to
the process in which "java ...." runs.  What I did is to manually start JServ
with the following script:

#!/bin/sh
# launch jserv in manual mode
jsdk=/path/to/jsdk.jar
jserv=/path/to/Apache-JServ.jar
props=/path/to/jserv.properties
log=/path/to/jserv.log
classes=$CLASSPATH:$jsdk:$jserv

DISPLAY=yourHostName:0
export DISPLAY

THREADS_FLAG=native
export THREADS_FLAG
/path/to/java  -Xms60m -Xmx120m  -classpath $classes org.apache.jserv.JServ
$props &> $log

Hope it can be of help. I guess that there might be some tricks that you can
try to let Apache server hand the DISPLAY env to java in autostart mode, but in
my case I just want to write the useful code and my production and development
environment also works more flexible with manual start option.

regards,

-Shaoping


Thad Humphries wrote:

> I'm running JServ 1.0b3 with Apache 1.3.4 on a Sun 2.6 server.
>
> I'm trying the image generation examples in Jason Hunter's book,
> specifically Example 6-1, HelloWorldGraphics.java.  This servlet uses AWT
> and Hunter warns that you should either unset or set DISPLAY.   I have set
> my DISPLAY to :0.0, exported DISPLAY, ran xhosts +, and restarted Apache.
> But when I run my servlet, I get an internal server error and this in my
> jserv.log:
>
> [23/03/1999 13:21:37:735] (ERROR) ajp11: Servlet Error:
> java.lang.InternalError: Can't connect to X11 window server using ':0.0' as
> the value of the DISPLAY variable.: Can't connect to X11 window server
> using ':0.0' as the value of the DISPLAY variable.
> [23/03/1999 13:21:37:736] (ERROR) an error returned handling request via
> protocol "ajpv11"
>
> I get the same response when I unset DISPLAY.
>
> So, who out there has done this?  How do I successfully set DISPLAY such
> that JServ can see it?
>
> --------------------------------------------------------------------------
> Thad Humphries                       "'Open Systems' means no fences. And
> Software Engineer (aka, Nerd)          no fences means no need for Gates."
> Phone: 540/675-3015, ext. 225                           - Sun Microsystems
>
EndPart: 0
Part: 1
Author-Set: masaya@eecs.ukans.edu
HideAttributions: 1
LastModifiedSecs: 938641938
Type: monospaced
Lines: 22
I had the same problem with using a servlet that does on the
fly graphics. I was looking at the same example from the Java
Servlet Programming book (Hunter & Crawford) and needed to set the
DISPLAY variable for the JVM where the servlets are running. Somebody
previously suggested that you start manually the JVM with the
appropriate "DISPLAY=<server name>:0" and export commands, but I
found a way to do it with the automatic startup mode. Go to the
"jserv.properties" file and look for the "wrapper.env" comments.
Basically, this is where you can set environment variables that the
JVM will see (none set by default). So add the following line:

wrapper.env=DISPLAY=<server name>:0

  Just make sure to substitue your server name in the line before and
I also found that in my case, I needed to execute the xhost command to
allow access to the X server running on my server. I also needed to
be logged on in order for this to work. Somebody else might explain
this one, but for now I just "xlock" the console (which nobody uses).
The previous faq notes that there is a virtual X server, maybe worth
checking out.

Hope this helps.
EndPart: 1
