RE: Image Scaling Code

2006-01-13 Thread Wouter Boers
That was the old way to fix a bug in the JVM I believe. Anyways nowadays you
can pass the following option to the server when starting:
-Djava.awt.headless=true 

That will prevent the errors mentioned below when you don't have a graphical
shell running on your system. 

Regards, Wouter

-Original Message-
From: Ben Kim [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 13, 2006 7:54 AM
To: Tomcat Users List
Subject: Re: Image Scaling Code


This may or may not be the case with you.

I had a similar error (X11, DISPLAY) with an earlier version of tomcat
included in a 3rd party package, on linux. 

After I installed Xvfb (x virtual frame buffer) server rpm, the error went
away. (http://www.xfree86.org/4.0.1/Xvfb.1.html) I think there was a clue in
the error log.

If you're on Fedora, you can just do yum install xorg-x11-Xvfb or do yum
search Xvfb. I don't think I had to run it actually. 

Don't know if it will help you, but just in case. 


Regards,

Ben Kim
Developer
http://benix.tamu.edu

On 1/12/06, Justin Jaynes [EMAIL PROTECTED] 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.clinit(X11GraphicsEnvironment.java:13
 1) java.lang.Class.forName0(Native Method)  java.lang.Class.forName(
 Class.java:164)  
 java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(
 GraphicsEnvironment.java:68)  
 sun.awt.X11.XToolkit.clinit(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 we'll bind it!




--
You can lead a horse to water

Re: Image Scaling Code

2006-01-13 Thread Jarrar Hussain

Hallo Wouter,

Yes I had the same problem and I add:

-Djava.awt.headless=true

option in

/usr/local/tomcat5/bin/catalina.sh

file like this:

CATALINA_OPTS=-Djava.awt.headless=true

and than everything works as expected.

Regards,
Jarrar.


Wouter Boers wrote:


That was the old way to fix a bug in the JVM I believe. Anyways nowadays you
can pass the following option to the server when starting:
-Djava.awt.headless=true 


That will prevent the errors mentioned below when you don't have a graphical
shell running on your system. 


Regards, Wouter

-Original Message-
From: Ben Kim [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 13, 2006 7:54 AM

To: Tomcat Users List
Subject: Re: Image Scaling Code


This may or may not be the case with you.

I had a similar error (X11, DISPLAY) with an earlier version of tomcat
included in a 3rd party package, on linux. 


After I installed Xvfb (x virtual frame buffer) server rpm, the error went
away. (http://www.xfree86.org/4.0.1/Xvfb.1.html) I think there was a clue in
the error log.

If you're on Fedora, you can just do yum install xorg-x11-Xvfb or do yum
search Xvfb. I don't think I had to run it actually. 

Don't know if it will help you, but just in case. 



Regards,

Ben Kim
Developer
http://benix.tamu.edu

On 1/12/06, Justin Jaynes [EMAIL PROTECTED] 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.clinit(X11GraphicsEnvironment.java:13
1) java.lang.Class.forName0(Native Method)  java.lang.Class.forName(
Class.java:164)  
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(
GraphicsEnvironment.java:68)  
sun.awt.X11.XToolkit.clinit(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

Re: Image Scaling Code

2006-01-13 Thread Dakota Jack
headless I think the command is.

On 1/12/06, Dakota Jack [EMAIL PROTECTED] wrote:

 You need to set a java command option so that your code won't search for a
 display.  Apparently you are using this with a server that has no monitor?
 I forget the option but look them up under the java command and it will be
 obviously.  It ends in less as I recall.

 On 1/12/06, Justin Jaynes [EMAIL PROTECTED] 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.clinit(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.clinit(
  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 we'll bind it!
 



 --
 You can lead a horse to water but you cannot make it float on its back.
 ~Dakota Jack~




--
You can lead a horse to water but you cannot make it float on its back.
~Dakota Jack~


RE: Image Scaling Code

2006-01-13 Thread Ben Kim

On Fri, 13 Jan 2006, Wouter Boers wrote:

That was the old way to fix a bug in the JVM I believe. Anyways nowadays you
can pass the following option to the server when starting:
-Djava.awt.headless=true 

This page seems to summarize it all ...

http://tomcat.apache.org/faq/unix.html
snip
  How do I run without an X server and still get graphics?

You either need to run headless or run an alternate X-server. Some more
information can be found here , here , or here .

Or if your are using a JVM 1.4 or better, you can use the system property
java.awt.headless=true
/snip

That will prevent the errors mentioned below when you don't have a graphical
shell running on your system. 

Regards, Wouter

-Original Message-
From: Ben Kim [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 13, 2006 7:54 AM
To: Tomcat Users List
Subject: Re: Image Scaling Code


This may or may not be the case with you.

I had a similar error (X11, DISPLAY) with an earlier version of tomcat
included in a 3rd party package, on linux. 

After I installed Xvfb (x virtual frame buffer) server rpm, the error went
away. (http://www.xfree86.org/4.0.1/Xvfb.1.html) I think there was a clue in
the error log.

If you're on Fedora, you can just do yum install xorg-x11-Xvfb or do yum
search Xvfb. I don't think I had to run it actually. 

Don't know if it will help you, but just in case. 


Regards,

Ben Kim
Developer
http://benix.tamu.edu

On 1/12/06, Justin Jaynes [EMAIL PROTECTED] 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.clinit(X11GraphicsEnvironment.java:13
 1) java.lang.Class.forName0(Native Method)  java.lang.Class.forName(
 Class.java:164)  
 java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(
 GraphicsEnvironment.java:68)  
 sun.awt.X11.XToolkit.clinit(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

Re: Image Scaling Code

2006-01-12 Thread Wendy Smoak
On 1/12/06, Justin Jaynes [EMAIL PROTECTED] wrote:

  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?

  javax.servlet.ServletException: Can't connect to X11 window server using 
 ':0.0' as the value of the DISPLAY variable.

This looks like a variation of the 'headless' problem.  (Are you
running X11 on the server?)

Try running Tomcat with:
   CATALINA_OPTS=-Djava.awt.headless=true

--
Wendy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Image Scaling Code

2006-01-12 Thread Mark Hagger
You need to have:

-Djava.awt.headless=true

in your java start up args, this will prevent it from trying to talk to an X 
server.  Obviously some image related stuff has to talk to an X server, but 
just ImageIO stuff is fine.

Mark


On Thursday 12 January 2006 19:31, Frank W. Zammetti 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(PageConte
 xtImpl.java:848) 
  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContext
 Impl.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.jav
 a: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.clinit(X11GraphicsEnvironment.java:131) 
  java.lang.Class.forName0(Native Method) 
  java.lang.Class.forName(Class.java:164) 
  java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironm
 ent.java:68)  sun.awt.X11.XToolkit.clinit(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.jav
 a: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 we’ll bind it!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For 

RE: Image Scaling Code

2006-01-12 Thread Lawrence, Gabriel
The environment variable is below:

JAVA_OPTS=-Djava.awt.headless=true

Cheers,
-gabe


Gabriel Lawrence
ACT Data Security Manager, UC San Diego


-Original Message-
From: Justin Jaynes [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 12, 2006 11:39 AM
To: Tomcat Users List; [EMAIL PROTECTED]
Subject: Re: Image Scaling Code

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(PageCont
extImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContex
tImpl.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.ja
va: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(GraphicsEnviron
ment.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.ja
va: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

Re: Image Scaling Code

2006-01-12 Thread Frank W. Zammetti

D'oh!  Now *THAT* rings a bell :)

Mark Hagger wrote:

You need to have:

-Djava.awt.headless=true

in your java start up args, this will prevent it from trying to talk to an X 
server.  Obviously some image related stuff has to talk to an X server, but 
just ImageIO stuff is fine.


Mark


On Thursday 12 January 2006 19:31, Frank W. Zammetti 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(PageConte
xtImpl.java:848) 
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContext
Impl.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.jav
a: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.clinit(X11GraphicsEnvironment.java:131) 
java.lang.Class.forName0(Native Method) 
java.lang.Class.forName(Class.java:164) 
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironm
ent.java:68)  sun.awt.X11.XToolkit.clinit(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.jav
a: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 we’ll bind it!



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: 

Re: Image Scaling Code

2006-01-12 Thread Tim Funk

FAQ .. http://tomcat.apache.org/faq/unix.html#x

-Tim

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?



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Image Scaling Code

2006-01-12 Thread Ryan McDonald
i believe adding this to your CATALINA_OPTS variable will solve this  
issue


-Djava.awt.headless=true


On 12-Jan-06, at 2:26 PM, 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 
(PageCont

extImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException 
(PageContex

tImpl.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.ja

va: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.clinit(X11GraphicsEnvironment.java: 
131)

java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:164)
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment 
(GraphicsEnviron

ment.java:68)  sun.awt.X11.XToolkit.clinit(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.ja

va: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 we'll bind it!




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Image Scaling Code

2006-01-12 Thread Dakota Jack
You need to set a java command option so that your code won't search for a
display.  Apparently you are using this with a server that has no monitor?
I forget the option but look them up under the java command and it will be
obviously.  It ends in less as I recall.

On 1/12/06, Justin Jaynes [EMAIL PROTECTED] 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.clinit(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.clinit(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 we'll bind it!




--
You can lead a horse to water but you cannot make it float on its back.
~Dakota Jack~


Re: Image Scaling Code

2006-01-12 Thread Ben Kim

This may or may not be the case with you.

I had a similar error (X11, DISPLAY) with an earlier version of tomcat
included in a 3rd party package, on linux. 

After I installed Xvfb (x virtual frame buffer) server rpm, the error went
away. (http://www.xfree86.org/4.0.1/Xvfb.1.html) I think there was a clue
in the error log.

If you're on Fedora, you can just do yum install xorg-x11-Xvfb or do
yum search Xvfb. I don't think I had to run it actually. 

Don't know if it will help you, but just in case. 


Regards,

Ben Kim
Developer
http://benix.tamu.edu

On 1/12/06, Justin Jaynes [EMAIL PROTECTED] 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.clinit(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.clinit(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 we'll bind it!




--
You can lead a horse to water but you cannot make it float on its back.
~Dakota Jack~


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Image Scaling Code

2006-01-12 Thread Ben Kim

Sorry, a correction to my post. I checked my server and found that Xvfb is
actually running on display 1.0. These are the processes.

Xvfb :1

bash -c export DISPLAY=:1.0; . /opt//tomcat.sh 

I'll have to dig up for the details of tweaking, but googling of tomcat
xvfb turned up a few like this.

http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg159956.html


Regards,

Ben Kim
Developer
http://benix.tamu.edu

-- Forwarded message --
Date: Fri, 13 Jan 2006 00:53:34 -0600 (CST)
From: Ben Kim [EMAIL PROTECTED]
To: Tomcat Users List users@tomcat.apache.org
Subject: Re: Image Scaling Code


This may or may not be the case with you.

I had a similar error (X11, DISPLAY) with an earlier version of tomcat
included in a 3rd party package, on linux. 

After I installed Xvfb (x virtual frame buffer) server rpm, the error went
away. (http://www.xfree86.org/4.0.1/Xvfb.1.html) I think there was a clue
in the error log.

If you're on Fedora, you can just do yum install xorg-x11-Xvfb or do
yum search Xvfb. I don't think I had to run it actually. 

Don't know if it will help you, but just in case. 


Regards,

Ben Kim
Developer
http://benix.tamu.edu

On 1/12/06, Justin Jaynes [EMAIL PROTECTED] 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.clinit(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.clinit(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