Few days back we received a requirement from client to generate an image out of our existing work flow definition. We started development using JgraphX to generate image for existing work flow. We wrote complete API tested this locally on Linux box, every thing is working properly. Once we deployed this in cloud (Amazon instance in our case) it started throwing HeadlessException because cloud instance is a Headless Environment.
Exception Log

Root Cause

We tried to search solution for this problem from Google and JGraph form as well, during the search we came across a thread in JGraphX form. Finally I went ahead and debugged the JGraphX code to figure out actual problem, so we can solve this issue. During debugging I came across a code in JGraphX library that it is trying to create Drag and Drop functionality, but I don't need this for my requirement. Same time I also came across a flag in Graph component to check isDragEnabled to validate that Drag and Drop service is required or not. This lib creates DragSource object irrespective of this flag is set or not.
After digging into the JGraphX code, I solved this problem by overriding installDragGestureHandler method of mxGraphHandler and createHandlers method mxGraphComponent class.

Disable Drag & Drop

Override installDragGestureHandler implementation to blank because my application does not require any Drag and Drop feature.
Install Drag Gesture Handler
MymxGraphHandler
MymxGraphComponent

Final Thought

This is an hack, I did to the existing JGraphX library to get it work in Headless environment.