headless env webapp

2011-05-28
2013-04-17
  • Marcos Lohmann
    Marcos Lohmann
    2011-05-28

    I am facing an error trying to use jpdf in a servlet (on tomcat6 in a headless ubuntu10)
    The awt.headless parameter in the system properties is "true", but still get this error…

    java.awt.HeadlessException
    java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:173)
    java.awt.Window.<init>(Window.java:476)
    java.awt.Frame.<init>(Frame.java:419)
    java.awt.Frame.<init>(Frame.java:384)

    gnu.jpdf.PDFGraphics.getFontMetrics(Unknown Source)
    br.com.mcloh.appl.utils.pdf.PDFHelper.addTextBlock(PDFHelper.java:84)

    PDFHelper.java(84) is:

    FontMetrics fm = pdfGraphics.getFontMetrics(font);

    1) font is and instance of java.awt.Font
    2) pdfGrapgics is job.getGraphics()
    3) job is instance of PDFJob
    4) OutputStream for job is a ServletOutputStream

    do you mind to help me find out the fix?