rkrug / plantuml

R package to build UML graphs using plantuml
https://rkrug.github.io/plantuml/index.html
GNU General Public License v3.0
76 stars 7 forks source link

java.awt.AWTError #1

Closed samssann closed 6 years ago

samssann commented 6 years ago
─ Session info ──────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.4.4 (2018-03-15)
 os       Ubuntu 16.04.5 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       Etc/UTC                     
 date     2018-09-25                  

─ Packages ──────────────────────────────────────────────────────────
 package     * version   date       source                         
 clisymbols    1.2.0     2017-05-21 CRAN (R 3.4.4)                 
 digest        0.6.12    2017-01-27 CRAN (R 3.2.3)                 
 DT            0.4       2018-01-30 CRAN (R 3.4.4)                 
 grImport      0.9-1     2018-06-18 CRAN (R 3.4.4)                 
 htmltools     0.3.6     2017-04-28 CRAN (R 3.4.4)                 
 htmlwidgets   1.2       2018-04-19 CRAN (R 3.4.4)                 
 magrittr      1.5       2014-11-22 CRAN (R 3.2.3)                 
 plantuml    * 0.2.2.1   2018-09-25 Github (rkrug/plantuml@c19355c)
 png           0.1-7     2013-12-03 CRAN (R 3.4.4)                 
 Rcpp          0.12.18   2018-07-23 CRAN (R 3.4.4)                 
 sessioninfo   1.0.0     2017-06-21 CRAN (R 3.4.4)                 
 withr         2.1.1     2017-12-19 CRAN (R 3.4.3)                 
 XML           3.98-1.13 2018-08-01 CRAN (R 3.4.4)                 
 yaml          2.1.14    2016-11-12 CRAN (R 3.2.3) 

Running: plot(as.plantuml(list(a = 1, b = 2)))

Produces the following error:

Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
    at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103)
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
    at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181)
    at net.sourceforge.plantuml.FileFormat.<clinit>(FileFormat.java:88)
    at net.sourceforge.plantuml.Option.<init>(Option.java:94)
    at net.sourceforge.plantuml.Run.main(Run.java:90)

Is there a way to set the -Djava.awt.headless=true option which presumably fixes this?

rkrug commented 6 years ago

You are likely right - I never tried it on a headless computer or one without GUI.

I won’t have time to look at it this week. You could try to run plantuml directly from the command line and see if it works from there? That would help, as I don’t have a Linux computer at hand.

I will see what I can do next week.

Thanks.

Von meinem iPhone gesendet

Am 25.09.2018 um 13:19 schrieb sam notifications@github.com:

─ Session info ────────────────────────────────────────────────────── setting value
version R version 3.4.4 (2018-03-15) os Ubuntu 16.04.5 LTS
system x86_64, linux-gnu
ui RStudio
language (EN)
collate en_US.UTF-8
tz Etc/UTC
date 2018-09-25

─ Packages ────────────────────────────────────────────────────────── package version date source
clisymbols 1.2.0 2017-05-21 CRAN (R 3.4.4)
digest 0.6.12 2017-01-27 CRAN (R 3.2.3)
DT 0.4 2018-01-30 CRAN (R 3.4.4)
grImport 0.9-1 2018-06-18 CRAN (R 3.4.4)
htmltools 0.3.6 2017-04-28 CRAN (R 3.4.4)
htmlwidgets 1.2 2018-04-19 CRAN (R 3.4.4)
magrittr 1.5 2014-11-22 CRAN (R 3.2.3)
plantuml
0.2.2.1 2018-09-25 Github (rkrug/plantuml@c19355c) png 0.1-7 2013-12-03 CRAN (R 3.4.4)
Rcpp 0.12.18 2018-07-23 CRAN (R 3.4.4)
sessioninfo 1.0.0 2017-06-21 CRAN (R 3.4.4)
withr 2.1.1 2017-12-19 CRAN (R 3.4.3)
XML 3.98-1.13 2018-08-01 CRAN (R 3.4.4)
yaml 2.1.14 2016-11-12 CRAN (R 3.2.3) Running: plot(as.plantuml(list(a = 1, b = 2)))

Produces the following error:

Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable. at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65) at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115) at java.security.AccessController.doPrivileged(Native Method) at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:74) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82) at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1181) at net.sourceforge.plantuml.FileFormat.(FileFormat.java:88) at net.sourceforge.plantuml.Option.(Option.java:94) at net.sourceforge.plantuml.Run.main(Run.java:90) Is there a way to set the -Djava.awt.headless=true option which presumably fixes this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

rkrug commented 6 years ago

Please see commit which adds an argument to plot.plantuml() to allow java options. You can use it as follow:

# to update to that commit
devtools::install_github("rkrug/plantuml", ref = "2a21cdc129848a995cefd2e6031e489c4a4c2fa5")
# 
x <- 5
plot(as.plantuml(x), java_opt = "-Djava.awt.headless=true")

Please let me know if it works.

samssann commented 6 years ago

@rkrug this works now. Thank you. R6 class support would be great : )

rkrug commented 6 years ago

Great.

Could you please file a new issue / feature request for R6 so that they don’t get lost? Thanks.

I myself have never used R6 classes, but at least the idea does not get lost and can be discussed in detail there.

On 31 Oct 2018, at 09:28, sam notifications@github.com wrote:

@rkrug this works now. Thank you. R6 class support would be great : )

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

-- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

University of Zürich

Cell: +41 (0)78 630 66 57 email: Rainer@krugs.de Skype: RMkrug

PGP: 0x0F52F982