I am using AWS Elasti Beanstalk to power one of my apps. In this I need to export a svg document to png,jpg, pdf etc. For this I use Apache Batik library. This provides excellent output on my local dev workstation but as soon as I deploy it on the EBS I start getting errors, all related to fonts. 

The error stacktrace was - 

```
Caused by: java.lang.Error: Probable fatal error:No fonts found. 
    at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1088) 
    at sun.font.FontManager.initialiseDeferredFont(FontManager.java:960) 
    at sun.font.FontManager.findOtherDeferredFont(FontManager.java:899) 
    at sun.font.FontManager.findDeferredFont(FontManager.java:916) 
    ...
    at sun.font.FontManager.findFont2D(FontManager.java:1904) 
    at sun.font.FontManager.initialiseDeferredFonts(FontManager.java:792) 
    at sun.java2d.SunGraphicsEnvironment.loadFonts(SunGraphicsEnvironment.java:468)
    at sun.awt.X11GraphicsEnvironment.loadFonts(X11GraphicsEnvironment.java:925) 
    at sun.java2d.SunGraphicsEnvironment.loadFontFiles(SunGraphicsEnvironment.java:498) 
    at sun.java2d.SunGraphicsEnvironment.getInstalledFontFamilyNames(SunGraphicsEnvironment.java:721) 
    at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:746) 
    at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:773) 
    at sun.java2d.HeadlessGraphicsEnvironment.getAvailableFontFamilyNames(HeadlessGraphicsEnvironment.java:99) 
    at org.apache.batik.gvt.font.FontFamilyResolver.(FontFamilyResolver.java:74) 
    at org.apache.batik.bridge.SVGTextElementBridge.getFontList(SVGTextElementBridge.java:1529) 
    at org.apache.batik.bridge.SVGTextElementBridge.getAttributeMap(SVGTextElementBridge.java:1610) 
    at org.apache.batik.bridge.SVGTextElementBridge.fillAttributedStringBuffer(SVGTextElementBridge.java:902) 
    at org.apache.batik.bridge.SVGTextElementBridge.buildAttributedString(SVGTextElementBridge.java:856) 
    at org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(SVGTextElementBridge.java:636)
    at org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(SVGTextElementBridge.java:292) 
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:224) 
    at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171) 
    at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208) 
    at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:92) 
    at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)

```

So I tried installing fonts as [one other stackoverflow answer suggests.](https://stackoverflow.com/questions/4438839/java-on-debian-probable-fatal-error-no-fonts-found) But this gave me a new error stacktrace -

```
Caused by: java.lang.NoClassDefFoundError: 
Could not initialize class org.apache.batik.gvt.font.FontFamilyResolver 
    at org.apache.batik.bridge.SVGTextElementBridge.getFontList(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.getAttributeMap(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.fillAttributedStringBuffer(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.buildAttributedString(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(Unknown Source) 
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source) 
    at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source) 
    at org.apache.batik.bridge.GVTBuilder.build(Unknown Source) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source) 
    at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source) 
    at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source) 

```

I dont understand why is this happening. Then I set `System.setProperty("java.awt.headless", "true");` just before I make a call to batik's transcoder. But this also generate the above error message. I am running out of options. 

Am I missing something? Can I do anything to add more context to this? Thanks for the help.