Thank you for the reply,
The class in my original post contains the following line:
font = Font.createFont(Font.TRUETYPE_FONT, fis);
This is what causes my application to stall. Another way the error
has come through is as the following:
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.<clinit>(X11GraphicsEnvironment.java:134)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:141)
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
java.awt.Font.initializeFont(Font.java:308)
java.awt.Font.<init>(Font.java:353)
java.awt.Font.createFont(Font.java:628)
com.words2walls.customquote.QuoteFontType.<init>(Unknown Source)
com.words2walls.customquote.QuoteFontType.<clinit>(Unknown Source)
com.words2walls.customquote.CustomQuote.getQuoteFontName(Unknown Source)
com.words2walls.webapp.filters.SessionQuoteFilter.doFilter(Unknown
Source)
You explanation makes sense. In the link you provided they mention a
better way to catch possible exceptions related to this. Since I
don't have graphics support on my server I must set this option.
Thanks,
Daniel
On 5/7/05, farhad <[EMAIL PROTECTED]> wrote:
> Look at this link:
> http://java.sun.com/j2se/1.4.2/docs/guide/awt/AWTChanges.html#headless
> This option is being used when you are operating on a machine without
> graphics support (usually in a server configuration). You will use the
> option for example when you want to do some AWT/Swing operation on the
> server side (image manipulation). You want to check and see if you have
> graphics support on your server (on unix/linux run something like xcalc
> on the server).
> Based on your information, it is your class that has problem and has
> nothing to do with graphics.
>
>
> Daniel Watrous wrote:
>
> >Is there at least someone that could tell me where to find more
> >information about the option "JAVA_OPTS=-Djava.awt.headless=true"?
> >What exactly is its purpose? Thanks in advance.
> >
> >Daniel
> >
> >On 5/6/05, Daniel Watrous <[EMAIL PROTECTED]> wrote:
> >
> >
> >>Hello,
> >>
> >>I have a web application that uses java.awt.Font objects to render
> >>images. The application will run in tomcat and that is where I have
> >>done development. When I first tried to run the application on a
> >>Linux box with Tomcat 5.0.25 I got the following error:
> >>
> >>java.lang.NoClassDefFoundError
> >> at com.words2walls.customquote.CustomQuote.getQuoteFontName(Unknown
> >> Source)
> >> at
> >> com.words2walls.webapp.filters.SessionQuoteFilter.doFilter(Unknown Source)
> >>
> >>Here is the code call that throws the error:
> >> public String getQuoteFontName() {
> >> return QuoteFontType.getInstance(this.quoteFontCode).toString();
> >> }
> >>
> >>And the class that is being called:
> >>/*
> >> * QuoteFontType.java
> >> *
> >> * Created on April 15, 2005, 9:41 AM
> >> */
> >>
> >>package com.words2walls.customquote;
> >>
> >>import java.awt.Font;
> >>import java.awt.FontFormatException;
> >>import java.util.*;
> >>import java.io.*;
> >>
> >>import com.words2walls.customquote.exceptions.FontNotFoundException;
> >>
> >>/**
> >> * Type safe enumeration of available fonts
> >> *
> >> * @author Daniel Watrous
> >> */
> >>public class QuoteFontType {
> >>
> >> private static final String pathToWebapp = "C:\\Program
> >>Files\\Apache Software Foundation\\Tomcat 5.0\\webapps\\words2walls";
> >> private static final String pathToPackage =
> >>"\\WEB-INF\\classes\\com\\words2walls\\fonts\\";
> >> private String fontName;
> >> private int fontCode;
> >> private Font font;
> >> private static org.apache.log4j.Category cat =
> >>
> >> org.apache.log4j.Category.getInstance(QuoteFontType.class.getName());
> >>
> >> public static final QuoteFontType ADORABLE = new
> >>QuoteFontType(1,"Adorable","adorable.ttf");
> >> private static final Map INSTANCES = new HashMap();
> >>
> >> static {
> >> cat.debug("Enter Static block to place fonts in INSTANCES Map");
> >> INSTANCES.put (ADORABLE.toInteger(), ADORABLE);
> >> cat.debug("Exit Static block with INSTANCES.size() = " +
> >>INSTANCES.size());
> >> }
> >>
> >> /** Creates a new instance of QuoteFontType */
> >> private QuoteFontType(int code, String fontName, String filename) {
> >> // create a font from the font file
> >> try {
> >> File fontFile = new File (pathToWebapp+pathToPackage+filename);
> >> FileInputStream fis = new FileInputStream(fontFile);
> >> font = Font.createFont(Font.TRUETYPE_FONT, fis);
> >> } catch (Exception e) {
> >> throw new FontNotFoundException(e);
> >> }
> >> // set member variables
> >> this.font = font;
> >> this.fontCode = code;
> >> this.fontName = fontName;
> >> }
> >>
> >> public String toString() {
> >> return fontName;
> >> }
> >>
> >> public Integer toInteger() {
> >> return new Integer(fontCode);
> >> }
> >>
> >> public static QuoteFontType getInstance(int code) {
> >> return (QuoteFontType) INSTANCES.get(new Integer(code));
> >> }
> >>
> >> public Font getFont() {
> >> return font;
> >> }
> >>
> >>}
> >>
> >>After some googling I found that if I set an environment variable
> >>"JAVA_OPTS=-Djava.awt.headless=true" that this error would go away.
> >>I'm not sure why this is the case, but it worked.
> >>
> >>I am now trying to test the application on a windows machine with
> >>Tomcat 5.0.30 and I get the same error. I have set a Windows XP
> >>environment variable the same as mentioned above. I have also added
> >>the option to the Java tab of the Tomcat monitor under Java Options:.
> >>
> >>What is the cause of this error? Is there some way that I can make it
> >>work on both Windows and Linux? Thanks in advance.
> >>
> >>Daniel
> >>
> >>
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]