Cannot Initialize CoreNLP in R - java

I am unable to access coreNLP in R on a Mac running High Sierra. I am uncertain what the problem is, but it seems that every time I try again to get coreNLP to work, I am faced with a different error. I have JDK 9.0.4. Please see my code below for what I am attempting to do, and the error that stops me.
My previous attempt I was able to get initCoreNLP() to run and load some elements of the packages, but it would fail on others. When I then attempted to run annotateString(), it would throw the error Error Must initialize with 'int CoreNLP'!.
I have downloaded and re-downloaded the coreNLP Java archive many times and still no luck! See image for contents of my coreNLP R package folder located at /Library/Frameworks/R.framework/Versions/3.4/Resources/library/coreNLP.
Do you know how I can successfully initialize coreNLP?
dyn.load("/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/lib/server/libjvm.dylib")
library(NLP)
library(coreNLP)
> downloadCoreNLP()
trying URL 'http://nlp.stanford.edu/software//stanford-corenlp-full-2015-12-09.zip'
Content type 'application/zip' length 403157240 bytes (384.5 MB)
==================================================
downloaded 384.5 MB
> initCoreNLP()
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Searching for resource: StanfordCoreNLP.properties
Error in rJava::.jnew("edu.stanford.nlp.pipeline.StanfordCoreNLP", basename(path)) :
edu.stanford.nlp.io.RuntimeIOException: ERROR: cannot find properties file "StanfordCoreNLP.properties" in the classpath!

Per our discussion.
My sense is your Java / R configuration dependency issue. Thus, it appears that rJava is dependent on the version of java used and coreNLP is dependent on rJava.
java <- rJava <- coreNLP
thus we can set the dlynlib version to 1.8.X, uninstall rJava, reinstall rJava then reinstall coreNLP.
Setup a particular version of java in RStudio
dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
remove.packages("rJava")
install.packages("rJava")
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
# usage
packages <- c("NLP", "coreNLP", "rJava")
ipak(packages)
.jinit()
.jcall("java/lang/System","S","getProperty","java.version")
# run the follwoing command once
# downloadCoreNLP() # <- Takes a while...
initCoreNLP()
example(getSentiment)
sIn <- "Mother died today. Or, maybe, yesterday; I can't be sure."
annoObj <- annotateString(sIn)

Related

Build OpenJDK 9 in CentOS5

I was trying to build OpenJDK 9 in Centos 5. I used
sh ./configure --disable-warnings-as-errors
make all
I am getting the following error.
Building target 'all' in configuration 'linux-x86_64-normal-server-release'
/root/jdk9/build/linux-x86_64-normal-server-
release/support/native/java.base/libjava/io_util_md.o: In function
`handleSetLength':
/root/jdk9/jdk/src/java.base/unix/native/libjava/io_util_md.c:228:
undefined reference to `fallocate64'
collect2: ld returned 1 exit status
/usr/bin/objcopy: '/root/jdk9/build/linux-x86_64-normal-server-
release/support/modules_libs/java.base/libjava.so': No such file
gmake[3]: *** [/root/jdk9/build/linux-x86_64-normal-server-
release/support/modules_libs/java.base/libjava.so] Error 1
gmake[2]: *** [java.base-libs] Error 2
ERROR: Build failed for target 'all' in configuration 'linux-x86_64-normal-
server-release' (exit code 2)
=== Output from failing command(s) repeated here ===
* For target support_native_java.base_libjava_BUILD_LIBJAVA_link:
/root/jdk9/build/linux-x86_64-normal-server-
release/support/native/java.base/libjava/io_util_md.o: In function
`handleSetLength':
/root/jdk9/jdk/src/java.base/unix/native/libjava/io_util_md.c:228:
undefined reference to `fallocate64'
collect2: ld returned 1 exit status
* All command lines available in /root/jdk9/build/linux-x86_64-normal-
server-release/make-support/failure-logs.
=== End of repeated output ===
No indication of failed target found.
Hint: Try searching the build log for '] Error'.
Hint: See common/doc/building.html#troubleshooting for assistance.
make[1]: *** [main] Error 2
make: *** [all] Error 2
I also tried other make targets such as make images and make install. But still getting the same error. My GCC version is gcc (GCC) 4.4.7 which I manually installed because Centos 5 by default has an older version.
Building JDK requires at least GCC 5.0 (see Building the JDK: CC).
This seems to be a problem in the glibc version (see redhat-issue, util-linux). So, updating your glibc to the latest version might solve it.
If you don't want to update your system's glibc, here is another alternative:
By looking at the man page of fallocate, we find that the description mentions that posix_fallocate(3) is a portable, POSIX.1-specified version of it, in case the mode parameter has the default value (0). The same applies to fallocate64.
Since all the occurrences of the aforementioned error already use the default mode value, you can replace them with posix_fallocate64() (instead of commenting them out as you mentioned in another comment).
The denoted man page says that:
This default behavior [of fallocate with mode=0] closely resembles the
behavior of the posix_fallocate(3) library function, and is intended
as a method of optimally implementing that function.

java.lang.NoClassDefFoundError error running RNetLogo on 64-bit Ubuntu 16.04 - but is the issue rJava or NetLogo?

The issue
I am attempting to start an instance of NetLogo in R using the RNetLogo package, which has rJava as a dependency.
During installation of rJava 0.9-9 (the latest development snapshot from rforge), I get the following errors:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
This appears to refer to Java version 6, even though I have version 8 only on my machine. However, the developer of rJava appears to say here that as long as the package installs and loads correctly, which it does, then users should ignore the warnings. Furthermore, .jinit() appears to run correctly:
> .jinit()
[1] 0
and the correct version of Java is detected:
> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12"
So, having loaded RNetLogo, I attempt to start a NetLogo instance. Here is the minimal code I'm running:
library(RNetLogo)
nl.path <- "~/NetLogo 6.0.2/app"
NLStart(nl.path, gui = FALSE, nl.jarname='netlogo-6.0.2.jar')
Which returns the following errors:
java.lang.NoClassDefFoundError: org/nlogo/workspace/Controllable
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
Caused by: java.lang.ClassNotFoundException
at RJavaClassLoader.findClass(RJavaClassLoader.java:383)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
I get the same issue using RStudio or running R from the terminal (including running as root).
My full sessionInfo():
R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS
Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 LC_PAPER=en_GB.UTF-8 LC_NAME=en_GB.UTF-8
[9] LC_ADDRESS=en_GB.UTF-8 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] RNetLogo_1.0-4 igraph_1.1.2 rJava_0.9-9
loaded via a namespace (and not attached):
[1] compiler_3.4.3 magrittr_1.5 tools_3.4.3 pkgconfig_2.0.1
Attempted fixes
Based on other users' issues that appear to be related, I also tried to following:
° Setting environment variables in /etc/profile.d/:
export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
export PATH="$PATH:$HOME/bin:$JAVA_HOME/bin"
export LD_LIBRARY_PATH="/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server"
export CLASSPATH="$ClASSPATH:$HOME/R/x86_64-pc-linux-gnu-library/3.4/rJava/java"
° Running
sudo R CMD javareconf -e
° Adding a couple of lines proposed as mac OS fixes to the start of my script:
Sys.setenv(NOAWT=1)
dyn.load('/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so')
Thanks in advance.
I spent a lot of time staring at this question, assuming I had the same issue because I was getting the same error. So, for future readers: On Ubuntu 17.10, with rJava 0.9-9, NetLogo 6.0.3 and RNetLogo 1.0-4, the same error results when using the Oracle 9 Java SDK. Going back to 8 solves it.
For the OP: The ~/ in nl.path might be the problem. On my system it doesn't work, but specifying the full path (that is, home/user_name/...) does.
I had the same problem with rNetLogo 1.0-4 for NetLogo 5.3.1 in combination with openjdk-8 on Ubuntu 16.04. I tried openjdk-8 and Oracle Java 8 (using ppa:webupd8team/java) with no luck.
In the end it works with rJava as Ubuntu package (r-cran-rjava) and going back to rNetLogo 1.0-0 (with I suppose did the trick), still using Oracle Java 8.
url = 'https://cran.r-project.org/src/contrib/Archive/RNetLogo/RNetLogo_1.0-0.tar.gz'
install.packages(url, repos=NULL, type="source")

GDAL error on CentOS 7

I’m no IT guy so it’s possible that I making something very wrong. But I’m struggling for days with this issue…
Working in a VM with CentOS 7.
When running something in GeoKettle I have this error that points to GDAL.
Native library load failed.
java.lang.UnsatisfiedLinkError: /home/geoairc/QGIS_Install/geokettle/libswt/linux/x86_64/libogrjni.so: liblcms.so.1: cannot open shared object file: No such file or directory
INFO 29-05 10:10:37,639 - OGR Input - wfs xml geodomus.0 - Finished processing (I=0, O=0, R=0, W=0, U=0, E=0)
Exception in thread "OGR Input - wfs xml geodomus.0 (Thread-10)" java.lang.UnsatisfiedLinkError: org.gdal.ogr.ogrJNI.RegisterAll()V
at org.gdal.ogr.ogrJNI.RegisterAll(Native Method)
at org.gdal.ogr.ogr.RegisterAll(ogr.java:110)
at org.pentaho.di.core.geospatial.OGRReader.open(OGRReader.java:75)
at org.pentaho.di.trans.steps.ogrfileinput.OGRFileInputMeta.getOutputFields(OGRFileInputMeta.java:277)
at org.pentaho.di.trans.steps.ogrfileinput.OGRFileInput.processRow(OGRFileInput.java:172)
at org.pentaho.di.trans.steps.ogrfileinput.OGRFileInput.run(OGRFileInput.java:342)
Someone pointed me that the error was caused by the lack of GDAL bindings to Java.
So I installed gdal-java RPM
https://www.rpmfind.net/linux/RPM/epel/7/x86_64/g/gdal-java-1.11.4-1.el7.x86_64.html
I installed but get successive dependency errors that can not get past (this is the first but when I try to install one of this got another set of dependencies errors):
[root#srvlgis01 tmp]# rpm -Uvh gdal-java-1.11.4-1.el7.x86_64.rpm
error: Failed dependencies:
gdal-libs(x86-64) = 1.11.4-1.el7 is needed by gdal-java-1.11.4-1.el7.x86_64
libgeotiff.so.1.2()(64bit) is needed by gdal-java-1.11.4-1.el7.x86_64
My GDAL version: gdal.x86_64 0:1.11.4-10.rhel7
Thanks in advance,
Pedro

Smart can't install...no package provides shared object file

Problem
I'm attempting to create a Bitbake recipe which will install Oracle JRE 8 onto my target OS.
I've tried to use metadata from meta-oracle-java, but had some difficulties due to one of the .inc files which are provided for general JREs has a JRE-7-specific URI.
I've changed some of the metadata from meta-oracle-java and created my own recipe to do this install.
Tests
A Build of the JRE Recipe by Itself
When building the recipe by itself:
bitbake oracle-jse-jre
The build completes without error. I've added a dependency on libav into the oracle-jse-jre recipe, so I can do the following from TMPDIR:
$ find . -name libavformat*so
./work/core2-64-poky-linux/libav/9.18-r0/sysroot-destdir/usr/lib/libavformat.so.54.20.4
./work/core2-64-poky-linux/libav/9.18-r0/sysroot-destdir/usr/lib/libavformat.so
./work/core2-64-poky-linux/libav/9.18-r0/sysroot-destdir/usr/lib/libavformat.so.54
./sysroots/genericx86-64/usr/lib/libavformat.so.54.20.4
./sysroots/genericx86-64/usr/lib/libavformat.so
./sysroots/genericx86-64/usr/lib/libavformat.so.54
Runtime Dependency Success
If I add the default package from the oracle-jse-jre recipe to RDEPENDS_${PN} of another recipe xenoros_0.1.bb, I can run bitbake xenoros and build without errors.
Core Image Failure
If I add xenoros to the IMAGE_INSTALL variable of a core-image-xenoros, the build fails with the following error:
ERROR: Unable to install packages. Command '/home/presslertj/yocto-OS/poky-jethro-build/build/tmp/sysroots/x86_64-linux/usr/bin/smart --log-level=warning --data-dir=/home/presslertj/yocto-OS/poky-jethro-build/build/tmp/work/genericx86_64-poky-linux/core-image-my-server/1.0-r0/rootfs/var/lib/smart install -y message-generation#core2_64 catkin#core2_64 python-distutils#core2_64 ldd#core2_64 xenoros#core2_64 rosgraph#core2_64 gedit#core2_64 actionlib#core2_64 python-compression#core2_64 dhcp-server#core2_64 libpthread-stubs#core2_64 tf2#core2_64 python-email#core2_64 catkin-dev#core2_64 git#core2_64 rosbash#core2_64 python-json#core2_64 python-wstool#core2_64 connman#core2_64 ros-config#core2_64 packagegroup-core-boot#genericx86_64 libsdl-1.2-0#core2_64 rosjava#core2_64 quagga#core2_64 nginx#core2_64 rospy#core2_64 apt#core2_64 libc6#core2_64 netcat#core2_64 shadow#core2_64 bash#core2_64 roscpp#core2_64 roslaunch#core2_64 run-postinsts#all python-rosinstall#core2_64 elfutils#core2_64 openssl#core2_64 font-alias#all gradle#core2_64 python-catkin-pkg#core2_64 catkin-runtime#core2_64 catkin-runtime-dev#core2_64 pciutils#core2_64 base-passwd#core2_64' returned 1:
Loading cache...
Updating cache... ######################################## [100%]
Computing transaction...error: Can't install oracle-jse-jre-1.8.0-u77r0#core2_64: no package provides libavformat.so.53(LIBAVFORMAT_53)(64bit)
ERROR: Function failed: do_rootfs
ERROR: Logfile of failure stored in: /home/presslertj/yocto-OS/poky-jethro-build/build/tmip/work/genericx86_64-poky-linux/core-image-my-server/1.0-r0/temp/log.do_rootfs.22073
ERROR: Task 7 (/home/presslertj/yocto-OS/poky-jethro-build/meta-myLayer/recipes-core/images/core-image-my-server.bb, do_rootfs) failed with exit code '1'
Looking inside TMPDIR, I can find this:
/sysroots/genericx86-64/usr/lib/libavformat.so.54
It seems there's a version mismatch, where smart expects version 53, but 54 is provided.
Reverting libav's version
Just to test what's going on, I've made a recipe which fetches version 0.8.17 of libav (which uses version 53). When using this instead of 9.18, I have the exact opposite problem, that smart expects but can't find version 54.
Questions
How does smart determine the version number for these shared object files?
What about the do_rootfs() task causes the build to fail at this specific time?
Is there a simple resolution to my specific problem?
1) It's not smart, but rather rpmbuild, that is adding dependencies derived from the ELF DT_NEEDED field (see elfutils -a).
2) The do_rootfs() task is failing because of unresolved dependencies.
3) Since you are using Poky/Yocto and rpm5, there is a simple way to mask the issue (substituting whatever dependencies are causing you heartburn)
echo "unresoved_dependency" > /etc/rpm/sysinfo/Providename
That is just a band-aid; you still need to figure out the packaging issues rather than masking the underlying problem with how you are building rpm packages.
For anyone that still encounter this error: as stated in the README file of the meta-oracle-java repo
There are some known install problems for JRE packages due to dependencies reported by RPM package manager.
Switching to DEB or IPK packaging temporarily fixes this.
ie:
PACKAGE_CLASSES = "package_deb"
or
PACKAGE_CLASSES = "package_ipk"
in your 'local.conf' file

Error in ls(envir = envir, all.names = private) : invalid 'envir' argument in R

I met with this error when I used a package in R for loading data, in this package, pakcage rJava was used.
Every time I run a function, the error is
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
This package has been proved without any problem, just some environment problem in my computer.
when I debugged, I found that in the last process before
ls(envir=envir,all.names = private )
the variable envir is NULL,which should be some value but not NULL I think.
After some trials, I kind of solved the problem, by installing rJava every time. And in addition, only when the error comes out, then I install 'rJava', it will work. If I install at the first, it won't work. So, I guess, installing 'rJava'(or probably installing packages), will cause some environment variables to change.
Either Java 7 and Java 8, including jdk or jre are tested, doesn't work. And for R, I am using the 3.1.3 R and all the packages are up to date.
Following is some information that I think may be useful for the troubleshooting.
By installing the package, jvm.dll needs to be added to the windows environment path: "Path" and I did that.
My sessionInfo is shown below:
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Danish_Denmark.1252 LC_CTYPE=Danish_Denmark.1252 LC_MONETARY=Danish_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=Danish_Denmark.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_0.9-1 fields_8.2-1 spam_1.0-1 raster_2.3-33 sp_1.0-17 ecomsUDG.Raccess_2.2-6
[7] downscaleR_0.5-2 maps_2.3-9 downscaleR.java_0.0-2 rJava_0.9-6 gWidgetsRGtk2_0.0-83 cairoDevice_2.22
[13] RGtk2_2.20.31 gWidgets_0.0-54 R.utils_2.0.0 R.oo_1.19.0 R.methodsS3_1.7.0
loaded via a namespace (and not attached):
[1] abind_1.4-3 bitops_1.0-6 boot_1.3-15 CircStats_0.2-4 colorspace_1.2-6 dtw_1.17-1 lattice_0.20-30 MASS_7.3-39
[9] munsell_0.4.2 plyr_1.8.1 proxy_0.4-14 Rcpp_0.11.5 RCurl_1.95-4.5 scales_0.2.4 tools_3.1.3 verification_1.41
Thank you for any help you can provide.
Have u fully solved your issue? i had a similar issue just a few days ago, sorted it out and would like to share with the community. Actually those wrapper functions (in my case, Rbbg package) call rJava functions had a log file in your user folder under C drive, you could delete those log files as it will enable you to escape from the the error message.
In my case, I need to delete the blpjavaapi0.log.0 and org.findata.blpwrapper.0 files created by Rbbg package.

Categories

Resources