bedatadriven / renjin-docs

Documentation for Renjin, the R interpreter for the JVM
7 stars 4 forks source link

Is it possible to load an RData file? #10

Closed pedromss closed 7 years ago

pedromss commented 7 years ago

I have an R script load.R that attempts to do

load("test.RData")

When I run:

engine.eval(new FileReader("load.R"))

An exception occurs:

Exception in thread "main" java.lang.NoClassDefFoundError: org/tukaani/xz/XZInputStream
    at org.renjin.primitives.io.connections.Connections.gzfile(Connections.java:79)
    at org.renjin.primitives.R$primitive$gzfile.doApply(R$primitive$gzfile.java:75)
    at org.renjin.primitives.R$primitive$gzfile.apply(R$primitive$gzfile.java:36)
    at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:45)
    at org.renjin.eval.Context.evaluateCall(Context.java:302)
    at org.renjin.eval.Context.evaluate(Context.java:222)
    at org.renjin.eval.Context.evaluate(Context.java:163)
    at org.renjin.sexp.Closure.doApply(Closure.java:83)
    at org.renjin.eval.ClosureDispatcher.apply(ClosureDispatcher.java:73)
    at org.renjin.eval.ClosureDispatcher.applyClosure(ClosureDispatcher.java:58)
    at org.renjin.sexp.Closure.apply(Closure.java:78)
    at org.renjin.eval.Context.evaluateCall(Context.java:302)
    at org.renjin.eval.Context.evaluate(Context.java:222)
    at org.renjin.primitives.special.AssignLeftFunction.assignLeft(AssignLeftFunction.java:57)
    at org.renjin.primitives.special.AssignLeftFunction.apply(AssignLeftFunction.java:41)
    at org.renjin.eval.Context.evaluateCall(Context.java:302)
    at org.renjin.eval.Context.evaluate(Context.java:222)
    at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:38)
    at org.renjin.eval.Context.evaluateCall(Context.java:302)
    at org.renjin.eval.Context.evaluate(Context.java:222)
    at org.renjin.primitives.special.IfFunction.apply(IfFunction.java:40)
    at org.renjin.eval.Context.evaluateCall(Context.java:302)
    at org.renjin.eval.Context.evaluate(Context.java:222)
    at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:38)
    at org.renjin.eval.Context.evaluateCall(Context.java:302)
    at org.renjin.eval.Context.evaluate(Context.java:222)
    at org.renjin.eval.Context.evaluate(Context.java:163)
    at org.renjin.sexp.Closure.doApply(Closure.java:83)
    at org.renjin.eval.ClosureDispatcher.apply(ClosureDispatcher.java:73)
    at org.renjin.eval.ClosureDispatcher.applyClosure(ClosureDispatcher.java:58)
    at org.renjin.sexp.Closure.apply(Closure.java:78)
    at org.renjin.eval.Context.evaluateCall(Context.java:302)
    at org.renjin.eval.Context.evaluate(Context.java:222)
    at org.renjin.eval.Context.evaluateExpressionVector(Context.java:285)
    at org.renjin.eval.Context.evaluate(Context.java:220)
    at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:145)
    at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:104)
    at com.infosistema.imp.restservice.data_treatment.DataTreatment.<init>(DataTreatment.scala:34)
    at com.infosistema.imp.restservice.data_treatment.Main$.<init>(DataTreatment.scala:45)
    at com.infosistema.imp.restservice.data_treatment.Main$.<clinit>(DataTreatment.scala)
    at com.infosistema.imp.restservice.data_treatment.Main.main(DataTreatment.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: org.tukaani.xz.XZInputStream
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 46 more
akbertram commented 7 years ago

It looks like you don't have Renjin's dependencies on your classpath. Take a look at the documentation on project setup: http://docs.renjin.org/en/latest/library/project-setup.html

pedromss commented 7 years ago

I have read the documentation and added the renjin engine dependency...

akbertram commented 7 years ago

The class org.tukaani.xz.XZInputStream is part of the org.tukaani:xz:1.0 and should be on your classpath as xz-1.0.jar -- but that doesn't seem to be the case.

It looks like you're running this from Intellij. Can you take a look at the first line of the console output? It should be the command line that launches the JVM and should include the full classpath, including xz-1.0.jar.

Do you have a different, newer version of org.tukaani:xz on your classpath? The md5sum of the xz-1.0.jar should be 8c53d7a772f11a88ee95c6ed0c215e49.

Perhaps IntelliJ is out of sync with your SBT file?