I aked Yaov Shapira if Java Questions were ok for this list. He said it was fine because this is a USER list for Tomcat. And java class programming has a great deal to do with using Tomcat.
"Frank W. Zammetti" <[EMAIL PROTECTED]> wrote: I don't quite see how this is Tomcat-related, but... Your code can't connect to your X server, which is necessary for many Java graphics-related functions to work on a *nix system. I dealt with this at one point when getting DataVision working on Linux, and I recall the solution being something to do with an environment variable, but the exact answer eludes me. Actually, it looks like you *have* defined the environment variable (DISPLAY in the stack trace rings a bell). Is X running? I believe it has to be for this to work. Frank Justin Jaynes wrote: > Hello all, > > I've written a java class to scale jpeg images. But I can't seem to get it to > work. Can anyone point me in the right direction? > > Here is my code: > > > package com.everybuddystree; > > import java.awt.*; > import java.awt.image.*; > import java.io.*; > import javax.imageio.*; > > public class ImageScaler { > > public ImageScaler() { > } > > public boolean scaleImageByWidth(String fileName, int newWidth) { > > File originalImage = new File(fileName); > try { > BufferedImage workingBufferedImage = ImageIO.read(originalImage); > int width = workingBufferedImage.getWidth(); > int height = workingBufferedImage.getHeight(); > Image workingImage = workingBufferedImage; > workingImage = (Image)workingImage.getScaledInstance(newWidth,-1,1); > BufferedImage finalImage = (BufferedImage)workingImage; > ImageIO.write(finalImage, "jpg", originalImage); > > return true; > > } catch (IOException ex){ > > return false; > > } > > } > > } > > When I run the pass an image to the class using a jsp I get the > following errors from Tomcat: > > > HTTP Status 500 - > --------------------------------- > type Exception report > message > description The server encountered an internal error () that prevented it > from fulfilling this request. > exception > javax.servlet.ServletException: Can't connect to X11 window server using > ':0.0' as the value of the DISPLAY variable. > org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848) > > org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781) > org.apache.jsp.image_jsp._jspService(org.apache.jsp.image_jsp:158) > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) > javax.servlet.http.HttpServlet.service(HttpServlet.java:802) > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) > javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root cause > java.lang.InternalError: Can't connect to X11 window server using ':0.0' as > the value of the DISPLAY variable. > sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) > sun.awt.X11GraphicsEnvironment.access$000(X11GraphicsEnvironment.java:53) > sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:142) > java.security.AccessController.doPrivileged(Native Method) > sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:131) > java.lang.Class.forName0(Native Method) > java.lang.Class.forName(Class.java:164) > java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68) > sun.awt.X11.XToolkit.(XToolkit.java:96) java.lang.Class.forName0(Native > Method) java.lang.Class.forName(Class.java:164) > java.awt.Toolkit$2.run(Toolkit.java:821) > java.security.AccessController.doPrivileged(Native Method) > java.awt.Toolkit.getDefaultToolkit(Toolkit.java:804) > java.awt.Image.getScaledInstance(Image.java:158) > com.everybuddystree.ImageScaler.scaleImageByWidth(ImageScaler.java:21) > org.apache.jsp.image_jsp._jspService(org.apache.jsp.image_jsp:114) > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) > javax.servlet.http.HttpServlet.service(HttpServlet.java:802) > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) > javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full > stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs. > > --------------------------------- > Apache Tomcat/5.5.12 > > > > > > > --------------------------------- > Yahoo! Photos Showcase holiday pictures in hardcover > Photo Books. You design it and well bind it! -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Yahoo! Photos Got holiday prints? See all the ways to get quality prints in your hands ASAP.