davidgohel / ReporteRs

Note that ReporteRs has been removed from CRAN the 16th of July 2018 and is not maintained anymore. please migrate to officer.
245 stars 44 forks source link

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException #187

Closed winterwang closed 7 years ago

winterwang commented 7 years ago

Hi I just started to try the example(docx) command and got this error:

example(docx) docx> ## No test: docx> # set default font size to 10 docx> options( "ReporteRs-fontsize" = 10 ) docx> # Create a new document docx> doc <- docx( title = "title" ) Error in .jnew(class.docx4r.document) : java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Here is the result of my sessionInfo() :

R version 3.3.3 (2017-03-06) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.2 LTS

locale: [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
[4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=en_GB.UTF-8 LC_ADDRESS=en_GB.UTF-8
[10] LC_TELEPHONE=en_GB.UTF-8 LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=en_GB.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] ReporteRs_0.8.8.9000 ReporteRsjars_0.0.2

loaded via a namespace (and not attached): [1] Rcpp_0.12.10 knitr_1.15.1 xml2_1.1.1 magrittr_1.5 munsell_0.4.3
[6] xtable_1.8-2 colorspace_1.3-2 R6_2.2.0 plyr_1.8.4 dplyr_0.5.0
[11] tools_3.3.3 grid_3.3.3 gtable_0.2.0 png_0.1-7 rvg_0.1.3
[16] R.oo_1.21.0 DBI_0.6-1 htmltools_0.3.5 lazyeval_0.2.0 digest_0.6.12
[21] assertthat_0.1 tibble_1.3.0 shiny_1.0.1 rJava_0.9-8 officer_0.1.1
[26] purrr_0.2.2 ggplot2_2.2.1 base64enc_0.1-3 R.utils_2.5.0 mime_0.5
[31] gdtools_0.1.4 scales_0.4.1 R.methodsS3_1.7.1 httpuv_1.3.3

Any suggestions? Thanks a lot!

davidgohel commented 7 years ago

Hi

Could you make sure you're not in one of the cases described here:

https://davidgohel.github.io/ReporteRs/articles/faq.html#rjava-hell

PS : If you are starting with ReporteRs, I suggests you to use officer instead.

winterwang commented 7 years ago

Thanks for your reply. I am pretty sure that I was stuck with the rJava package installation initially. However after looking into the solution suggested from here: Unable to install rJava in R 3.0 in Ubuntu 13.04 by using sudo ln -s /usr/lib/java-9-oracle/lib/server/libjvm.so /usr/lib/ in terminal. I am using the latest version of java (java-9-oracle) on my machine. Do you think that could be the reason that lead to this error?

Anyway, I found that I fixed the installation of it and I can also load the package without any warning message until I started to try example(docx) or example(pptx).

Many thanks for your help.

davidgohel commented 7 years ago

thanks

I don't know, probably something to configure in the system (which is what you did).

David

winterwang commented 7 years ago

Hi, I know that you have closed this issue. But I think I have to add more information in case someone else may run into the same issue. It turns out that with Java-8, the example(docx) and example(pptx) run smoothly and with no more warnings or errors. Probably because Java-9 on linux is still not stable and under development. Here are the steps I've done on my machine:

  1. sudo apt-get purge oracle-java9-installer to uninstall java-9-oracle from my system
  2. sudo apt-get install oracle-java8-installer to install java-8-oracle.
  3. sudo updatedb then locate libjvm.so get the path to the installed java, in my case, I got /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so
  4. sudo ln -s /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so /usr/lib/
  5. Then go back to Rstudio and library(ReportRs); example(docx) And here is the output : selection_020
davidgohel commented 7 years ago

Thanks for that, I will add a link to your solution in the FAQ later.