rdpstaff / classifier

RDP extensible sequence classifier for fungal lsu, bacterial and archaeal 16s
GNU General Public License v2.0
53 stars 32 forks source link

Problem with taxasim in headless mode #8

Open iimog opened 9 years ago

iimog commented 9 years ago

When running the subcommand taxasim in an environment without a X11 server an Exception is thrown at the end of execution:

java -jar classifier.jar taxa-sim rdp.tax rdp.fa rdp.fa taxasim 8 rankFile sab
100
200
300
... [truncated]
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using 'localhost:12.0' as the value of the DISPLAY variable.
        at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
        at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:62)
        at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:178)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:142)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:190)
        at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
        at sun.swing.SwingUtilities2.isLocalDisplay(SwingUtilities2.java:1406)
        at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:1563)
        at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:147)
        at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1599)
        at javax.swing.UIManager.setLookAndFeel(UIManager.java:530)
        at javax.swing.UIManager.setLookAndFeel(UIManager.java:570)
        at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1320)
        at javax.swing.UIManager.initialize(UIManager.java:1407)
        at javax.swing.UIManager.maybeInitialize(UIManager.java:1395)
        at javax.swing.UIManager.getDefaults(UIManager.java:644)
        at javax.swing.UIManager.getColor(UIManager.java:686)
        at org.jfree.chart.JFreeChart.<clinit>(JFreeChart.java:261)
        at org.jfree.chart.ChartFactory.createXYLineChart(ChartFactory.java:1748)
        at edu.msu.cme.rdp.classifier.train.validation.distance.TaxaSimilarityMain.createPlot(TaxaSimilarityMain.java:324)
        at edu.msu.cme.rdp.classifier.train.validation.distance.TaxaSimilarityMain.main(TaxaSimilarityMain.java:385)
        at edu.msu.cme.rdp.classifier.cli.ClassifierMain.main(ClassifierMain.java:79)

The plot is not generated and the txt output is incomplete. This error can be avoided by invocing the classifier in headless mode:

java -Djava.awt.headless=true -jar classifier.jar taxa-sim rdp.tax rdp.fa rdp.fa taxasim 8 rankFile sab

This workaround should be documented or else the problem can be fixed in code by adding

System.setProperty("java.awt.headless", "true");

before any graphics code (e.g. in a static {} block) See this post on Stack Overflow.

Cheers, Markus Ankenbrand

wangqion commented 9 years ago

Thanks a lot for your feedback and suggestions. We will update our document and the source code.