If you're executing java remotely you have to point display to your X11 server
before executing the servlet engine:
DISPLAY=[x server hostname]:0.0
export DISPLAY
The problem is that you have to be logged in in order for this to work. You
can't start the engine and then log out. (At least that's the case on HP-UX).
Someone suggested xvfb but I don't know how it works. Do you just point display
to the box that's running this? Is xvfb a deamon that runs in background?
dave.
Ryan Suther wrote:
> I am getting the following error - and I have an xserver running. Below is
> the servlet and the error I'm getting in jserv.log.
>
> Any help would be appreciated!
> ==========================================================
> jserv.log:
>
> [01/11/1999 13:15:35:710 EST] Servlet-Error: java.lang.NoClassDefFoundError:
> sun/awt/X11GraphicsEnvironment: sun/awt/X11GraphicsEnvironment
> [01/11/1999 13:15:35:713 EST] java.lang.NoClassDefFoundError:
> sun/awt/X11GraphicsEnvironment
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Compiled Code)
> at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Compiled
> Code)
> at java.awt.image.BufferedImage.createGraphics(Compiled Code)
> at java.awt.image.BufferedImage.getGraphics(Compiled Code)
> at C2Chart.doPost(Compiled Code)
> at C2Chart.doGet(Compiled Code)
> at javax.servlet.http.HttpServlet.service(Compiled Code)
> at javax.servlet.http.HttpServlet.service(Compiled Code)
> at org.apache.jserv.JServConnection.processRequest(Compiled Code)
> at org.apache.jserv.JServConnection.run(Compiled Code)
> at java.lang.Thread.run(Compiled Code)
> ===========================================================
> chart.java:
>
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.awt.*;
> import java.awt.image.*;
> import Acme.JPM.Encoders.*;
>
> public class chart extends HttpServlet {
>
> public void init(ServletConfig config)
> throws ServletException
> {
> super.init(config);
> }
>
> // Process the HTTP GET request
> public void doGet(HttpServletRequest request, HttpServletResponse
> response)
> throws ServletException, IOException
> {
> doPost(request, response);
> }
>
> // Process the HTTP POST request
> public void doPost(HttpServletRequest request, HttpServletResponse
> response)
> throws ServletException, IOException
> {
> BufferedImage image = new BufferedImage(200, 200,
> BufferedImage.TYPE_INT_RGB);
> Graphics g = image.getGraphics();
> g.setColor(Color.white);
> g.fillRect(0, 0, 200, 200);
> g.setColor(Color.red);
> g.drawOval(0, 0, 100, 150);
>
> response.setContentType("image/gif");
> ServletOutputStream out = response.getOutputStream();
> GifEncoder encoder = new GifEncoder(image, out);
> encoder.encode();
> out.close();
> }
>
> // Get servlet information...
> public String getServletInfo()
> {
> return "Chart Servler Information";
> }
> }
>
> -----Original Message-----
> From: Tim Panton - Westhawk Ltd [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 01, 1999 6:32 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [SERVLET-INTEREST] Creation of Image in Servlet!
>
> actually you may be able to do
> what you want -if you have the
> ability to change the web server
> start up script.
> You need to run a thing called xvfb,
> which is an xserver that has no
> display. It is shipped on most Linux
> disks.
> Change your web server startup script to in start it too and your
> servlet should work.
>
> T.
>
> William Worth <[EMAIL PROTECTED]> wrote:
> __________
> >I really don't think you can.. I mean as far as i can tell you want to
> display
> >graphical content generated on your servlet machine, directly onto a client
> >machine without going through a web browser. This is impossible in win32
> >(unless youv'e got an X server of course + your'e server is running UNIX),
> >possible in X, but as Craig said, you would need permission (via xauth or
> no
> >access restrctions on the X server (unlikely)) to access the X server...
> >If you want to disply GUI content in a browser then you Have to use http,
> you
> >coud use applets, ActiveX, java script whatever..
> >
> >Hope that helps a little.
> >
> >William.
> >
> >On Sat, 30 Oct 1999, you wrote:
> >> John John Tobias wrote:
> >>
> >> > Hi All,
> >> >
> >> > I hope you don't mind if i'll post this again, i just need your
> comments,
> >> > suggestion etc about this matter. I just want to know if the java
> servlet
> >> > has any restriction or limitation in inheriting java classes especially
> the
> >> > java.awt.*, applet, ... packages? Because i will create an image within
> the
> >> > servlet itself and call the class and some methods like this
> >> > Image image = createImage(MemoryImageSouce(..)), when i compiled
> there's no
> >> > error, but when the times i access it the java web server report an
> error
> >> > like this
> >> >
> >>
> >> When you are running on a Unix platform, you must have an X-Windows
> server
> >> running in order for AWT to work, and the username you are running your
> >> servlets under must have permissions to connect to it. This is true even
> if
> >> you are not displaying anything graphical on the server's console.
> >>
> >> For the gory details, you'll have to ask someone else (I haven't yet
> needed to
> >> create images dynamically), but this question regularly comes up for both
> >> servlets and standalone Java applications.
> >>
> >> Craig McClanahan
> >>
> >>
> ___________________________________________________________________________
> >> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> >> of the message "signoff SERVLET-INTEREST".
> >>
> >> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >> Resources: http://java.sun.com/products/servlet/external-resources.html
> >> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >--
> >
> >The primary cause of failure in electrical appliances is an expired
> >warranty. Often, you can get an appliance running again simply by
> >changing the warranty expiration date with a 15/64-inch felt-tipped
> >marker.
> > -- Dave Barry, "The Taming of the Screw"
> >
> >william:~#
> >
> >___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources: http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
> URL http://www.westhawk.co.uk/
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
--
David Mossakowski [EMAIL PROTECTED]
http://www.dwdog.com/styk 212.310.7275
"I don't sit idly by, I'm planning a big surprise"
F U G A Z I
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html