Error on Reading in a json file with Spark R

237 Views Asked by At

I am trying to follow a tutorial in SparkR. I follow the setup as required. But as soon as I try the function "read.json(path)" I get the following error:

"Error in invokeJava(isStatic = FALSE, objId$id, methodName, ...) : 
  java.lang.reflect.InvocationTargetException
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at      sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)..."

I am running R 3.3.2 and Java JDK 1.8 as requested in the tutorial. I attach images of the code and the results:

Is my Java being found, is it the right version?

The image is in R studio showing the code on the left and the console result on the right:

enter image description here

1

There are 1 best solutions below

0
On

Solution:

The spark-submit or sparkR instance is there.

Using the hdfs//...path put the json file on the Hadoop hdfs:

hadoop-2.0.2\bin> hadoop fs -put "/example/../people.json" "/user/../people.json"

Then use

people <- read.df (sqlContext, "/user/../people.json","json") 

to read the json and create dataframe 'people'.

Above steps worked for me after I made necessary changes in the example dataframe.R.