Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-913

Avoid java.awt.HeadlessException when using WMF transcoder functionality

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Duplicate
    • Affects Version/s: 1.7
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Operating System: Linux
      Platform: All

      Description

      I was using Batik with Jasper with some WMF images.

      Everything was working perfectly in my Windows GUI environmenet.
      But after deploying to server without available display GUI I got java.awt.HeadlessException.
      Setting -Djava.awt.headless=true was not sufficient.

      I started small investigation and I identified the problem:
      Toolkit.getDefaultToolkit().getScreenResolution().

      I modified two classes (attached AbstractWMFReader and AbstractWMFPainter) which use this call with a simple workaround.
      1. only one call to this method is needed (subsequent calls can use final static variable already declared).
      2. If a HeadlessException is thrown, we assume (hardcoded) resolution 96 (current value from my GUI environment).
      I think it is better to have this hardcoded output than thrown exception.

      I tested this new classes and result was OK without thrown Exception.

      I past my minor changes fot the case that someone else would appreciate server-side functionality for reading WMF files.

        Attachments

        1. BatikWMF-transcoder.zip
          13 kB
          Gabriel Gajdos
        2. Batik-Bug47277-ProposedFix.patch
          3 kB
          Helder Magalhães

          Issue Links

            Activity

              People

              • Assignee:
                batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
                Reporter:
                gabriel.gajdos@ipdap.sk Gabriel Gajdos
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: