Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.IllegalAccessException: class RJavaTools cannot access a member of class java.util.ArrayList$Itr (in module java.base) with modifiers "public" #147

Closed
NiccoloSalvini opened this issue Jun 23, 2022 · 11 comments

Comments

@NiccoloSalvini
Copy link

Hi,
I have a problem reading a pdf table. The link and the pdf document are not corrupted (e.g. pdftools::pdf_text() works fine, but I when I am trying to extract tables:

## rJava loads successfully
# install.packages("rJava")
library(rJava)
library(tabulizer)
out = extract_tables("https://www.aifa.gov.it/documents/20142/1626083/report_n.12_monitoraggio_antivirali_10.06.2022.pdf")

I get the following error:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
  java.lang.IllegalAccessException: class RJavaTools cannot access a member of class java.util.ArrayList$Itr (in module java.base) with modifiers "public"

with the following traceback:

6: stop(structure(list(message = "java.lang.IllegalAccessException: class RJavaTools cannot access a member of class java.util.ArrayList$Itr (in module java.base) with modifiers \"public\"", 
       call = .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", 
           cl, .jcast(if (inherits(o, "jobjRef") || inherits(o, 
               "jarrayRef")) o else cl, "java/lang/Object"), .jnew("java/lang/String", 
               method), j_p, j_pc, use.true.class = TRUE, evalString = simplify, 
           evalArray = FALSE), jobj = new("jobjRef", jobj = <pointer: 0x1506acf38>, 
           jclass = "java/lang/IllegalAccessException")), class = c("IllegalAccessException", 
   "ReflectiveOperationException", "Exception", "Throwable", "Object", 
   "error", "condition")))
5: .jcheck(silent = FALSE)
4: .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, 
       .jcast(if (inherits(o, "jobjRef") || inherits(o, "jarrayRef")) o else cl, 
           "java/lang/Object"), .jnew("java/lang/String", method), 
       j_p, j_pc, use.true.class = TRUE, evalString = simplify, 
       evalArray = FALSE)
3: .jrcall(x, name, ...)
2: guessesIterator$hasNext()
1: extract_tables("https://www.aifa.gov.it/documents/20142/1626083/report_n.12_monitoraggio_antivirali_10.06.2022.pdf", 
       encoding = "UTF-8")

devtools::session_info()

─ Session info ─
 setting  value
 version  R version 4.2.0 (2022-04-22)
 os       macOS Monterey 12.4
 system   aarch64, darwin20
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Rome
 date     2022-06-23
 rstudio  2022.02.2+485 Prairie Trillium (desktop)
 pandoc   NA

─ Packages ─
 package       * version date (UTC) lib source
 assertthat      0.2.1   2019-03-21 [1] CRAN (R 4.2.0)
 brio            1.1.3   2021-11-30 [1] CRAN (R 4.2.0)
 cachem          1.0.6   2021-08-19 [1] CRAN (R 4.2.0)
 callr           3.7.0   2021-04-20 [1] CRAN (R 4.2.0)
 cli             3.3.0   2022-04-25 [1] CRAN (R 4.2.0)
 crayon          1.5.1   2022-03-26 [1] CRAN (R 4.2.0)
 DBI             1.1.2   2021-12-20 [1] CRAN (R 4.2.0)
 desc            1.4.1   2022-03-06 [1] CRAN (R 4.2.0)
 devtools      * 2.4.3   2021-11-30 [1] CRAN (R 4.2.0)
 dplyr           1.0.9   2022-04-28 [1] CRAN (R 4.2.0)
 ellipsis        0.3.2   2021-04-29 [1] CRAN (R 4.2.0)
 fansi           1.0.3   2022-03-24 [1] CRAN (R 4.2.0)
 fastmap         1.1.0   2021-01-25 [1] CRAN (R 4.2.0)
 fs            * 1.5.2   2021-12-08 [1] CRAN (R 4.2.0)
 generics        0.1.2   2022-01-31 [1] CRAN (R 4.2.0)
 glue            1.6.2   2022-02-24 [1] CRAN (R 4.2.0)
 here          * 1.0.1   2020-12-13 [1] CRAN (R 4.2.0)
 lifecycle       1.0.1   2021-09-24 [1] CRAN (R 4.2.0)
 magrittr        2.0.3   2022-03-30 [1] CRAN (R 4.2.0)
 memoise         2.0.1   2021-11-26 [1] CRAN (R 4.2.0)
 pillar          1.7.0   2022-02-01 [1] CRAN (R 4.2.0)
 pkgbuild        1.3.1   2021-12-20 [1] CRAN (R 4.2.0)
 pkgconfig       2.0.3   2019-09-22 [1] CRAN (R 4.2.0)
 pkgload         1.2.4   2021-11-30 [1] CRAN (R 4.2.0)
 png             0.1-7   2013-12-03 [1] CRAN (R 4.2.0)
 prettyunits     1.1.1   2020-01-24 [1] CRAN (R 4.2.0)
 processx        3.6.0   2022-06-10 [1] CRAN (R 4.2.0)
 ps              1.7.0   2022-04-23 [1] CRAN (R 4.2.0)
 purrr           0.3.4   2020-04-17 [1] CRAN (R 4.2.0)
 R6              2.5.1   2021-08-19 [1] CRAN (R 4.2.0)
 ragg          * 1.2.2   2022-02-21 [1] CRAN (R 4.2.0)
 remotes         2.4.2   2021-11-30 [1] CRAN (R 4.2.0)
 rJava         * 1.0-6   2021-12-10 [1] CRAN (R 4.2.0)
 rlang           1.0.2   2022-03-04 [1] CRAN (R 4.2.0)
 rprojroot       2.0.3   2022-04-02 [1] CRAN (R 4.2.0)
 sessioninfo     1.2.2   2021-12-06 [1] CRAN (R 4.2.0)
 systemfonts     1.0.4   2022-02-11 [1] CRAN (R 4.2.0)
 tabulizer     * 0.2.2   2022-06-22 [1] Github (ropensci/tabulizer@3049a79)
 tabulizerjars * 1.0.1   2022-06-22 [1] Github (ropensci/tabulizerjars@d1924e0)
 testthat        3.1.4   2022-04-26 [1] CRAN (R 4.2.0)
 textshaping     0.3.6   2021-10-13 [1] CRAN (R 4.2.0)
 tibble          3.1.7   2022-05-03 [1] CRAN (R 4.2.0)
 tidyselect      1.1.2   2022-02-21 [1] CRAN (R 4.2.0)
 usethis       * 2.1.6   2022-05-25 [1] CRAN (R 4.2.0)
 utf8            1.2.2   2021-07-24 [1] CRAN (R 4.2.0)
 vctrs           0.4.1   2022-04-13 [1] CRAN (R 4.2.0)
 withr           2.5.0   2022-03-03 [1] CRAN (R 4.2.0)

 [1] /Users/niccolo/Library/R/arm64/4.2/library
 [2] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library

───
@jbryer
Copy link

jbryer commented Jun 29, 2022

I am getting the same error. I have a job I run once a year. It worked fine last year. Following.

@ggSamoora
Copy link

I found a solution to this problem. You have to use an older version of JDK for this to work. I created a 10-minute tutorial on how to properly set up the Tabulizer package. You can find the YouTube video here

@BastienNguyen
Copy link

Can you please provide a osx method too?

@ssingh13-rms
Copy link

I found a solution to this problem. You have to use an older version of JDK for this to work. I created a 10-minute tutorial on how to properly set up the Tabulizer package. You can find the YouTube video here

What's the version of JDK you used?

@drpedapati
Copy link

drpedapati commented Aug 14, 2022

Can you please provide a osx method too?

Go here and download Java 8 https://www.azul.com/downloads/?version=java-8-lts&package=jdk
Recommend DMG package and install
Uninstall any other Java VMs https://docs.azul.com/core/zulu-openjdk/uninstall/macos
Check at terminal:
javac -version
javac 1.8.0_345

Now you should be able to run extract_tables

I'm not a java developer but the versioning is confusing

@beatrizmilz
Copy link

Thank you so much @drpedapati !! I use Mac OS, with M1 chip, and was having a hard time to install tabulizer. Your last tip, to uninstall other java VMs, and install Java 8, worked well!

Can you please provide a osx method too?

Go here and download Java 8 https://www.azul.com/downloads/?version=java-8-lts&package=jdk Recommend DMG package and install Uninstall any other Java VMs https://docs.azul.com/core/zulu-openjdk/uninstall/macos Check at terminal: javac -version javac 1.8.0_345

Now you should be able to run extract_tables

I'm not a java developer but the versioning is confusing

@pachadotdev
Copy link
Contributor

Thanks! I had the exact same problem on Windows. I'll try to increase Tabula version in the source.

@tomwagstaff-opml
Copy link

Has anyone found a solution that doesn't involve rolling back the Java version? I haven't got admin permissions to do that...

@pachadotdev
Copy link
Contributor

pachadotdev commented Nov 17, 2023

Has anyone found a solution that doesn't involve rolling back the Java version? I haven't got admin permissions to do that...

not yet

@pachadotdev
Copy link
Contributor

works with OpenJDK11 now :)

@pachadotdev
Copy link
Contributor

fixed in 1.0.5-3 (https://cran.r-project.org/package=tabulapdf)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants