When java -jar execute, JavaEsSpark.esRDD raise ExceptionInInitializerError
See original GitHub issueWhat kind an issue is this?
- [ * ] Bug report. If you’ve found a bug, please provide a code snippet or test to reproduce it below.
The easier it is to track down the bug, the faster it is solved. - Feature Request. Start by telling us what problem you’re trying to solve.
Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.
Issue description
I am developing part of spark (v2.4.3) which reads elasticsearch (v7.3.0) on spring-boot 2 (web) using es-hadoop (v7.3.1).
** ref https://www.elastic.co/guide/en/elasticsearch/hadoop/master/spark.html
When I run it with “mvn spring-boot:run” it works fine.
But, When I run it with “java -jar output.jar”, JavaEsSpark make error about accessing elasticsearch. I thought in many ways but I don’t know why.
“ExceptionInInitializerError: null … RestService” “sql.DefaultSource15 could not be instantiated” “URI is not a hierarchical … version.”
I ask for your help (-.-)
** ps. I checked packages in jar file. => OK. I tried with SparkSession, but also fail. (java -jar execution)
Steps to reproduce
Code:
LOGGER.info("SpringBootSpark To Elasticsearch Application: {}, {}, {}, {}"
, appName, nodes, port, sparkHome);
String master = "local[*]";
SparkConf conf = new SparkConf()
.setAppName(appName)
.setSparkHome(sparkHome)
.setMaster(master)
.set("spark.executor.memory", "2g")
.set("spark.driver.memory", "2g")
.set("spark.eventLog.enabled","false")
.set("es.nodes.wan.only", "true")
.set("es.nodes", nodes)
.set("es.port", port)
.set("es.mapping.id", "id")
.set("es.write.operation", "upsert")
.set("es.index.read.missing.as.empty", "true");
JavaSparkContext jsc = new JavaSparkContext(conf);
// for DEBUG
System.out.println("\n\n==================================\n");
System.out.println(Arrays.stream(jsc.getConf().getAll()).map(t->{
return t._1()+"="+t._2();
}).collect(Collectors.joining(", ")));
JavaPairRDD<String, Map<String, Object>> esRDD =
JavaEsSpark.esRDD(jsc, resource, "?q=datasource:sample");
System.out.println("\n**count = "+esRDD.count());
Strack trace:
java.lang.ExceptionInInitializerError: null
at org.elasticsearch.hadoop.rest.RestService.findPartitions(RestService.java:216) ~[elasticsearch-hadoop-7.3.1.jar!/:7.3.1]
at org.elasticsearch.spark.rdd.AbstractEsRDD.esPartitions$lzycompute(AbstractEsRDD.scala:79) ~[elasticsearch-hadoop-7.3.1.jar!/:7.3.1]
at org.elasticsearch.spark.rdd.AbstractEsRDD.esPartitions(AbstractEsRDD.scala:78) ~[elasticsearch-hadoop-7.3.1.jar!/:7.3.1]
at org.elasticsearch.spark.rdd.AbstractEsRDD.getPartitions(AbstractEsRDD.scala:48) ~[elasticsearch-hadoop-7.3.1.jar!/:7.3.1]
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:253) ~[spark-core_2.11-2.4.3.jar!/:2.4.3]
...
Caused by: java.lang.IllegalArgumentException: URI is not hierarchical
at java.io.File.<init>(File.java:418) ~[na:1.8.0_121]
at org.elasticsearch.hadoop.util.IOUtils.toCanonicalFilePath(IOUtils.java:242) ~[elasticsearch-hadoop-7.3.1.jar!/:7.3.1]
at org.elasticsearch.hadoop.util.Version.<clinit>(Version.java:66) ~[elasticsearch-hadoop-7.3.1.jar!/:7.3.1]
... 27 common frames omitted
Version Info
OS: : MacOS lastest JVM : 1.8 Hadoop/Spark: null/2.4.3 ES-Hadoop : 7.3.1 ES : 7.3.0
Feature description
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
I try as your advice.
jar -tf target/agensspark-0.0.1-SNAPSHOT.jar | grep elastic ==> Nothing
java -jar target/agensspark-0.0.1-SNAPSHOT.jar -cp ~/Servers/es-hadoop/dist/elasticsearch-hadoop-7.3.1.jar ==> Caused by: java.lang.ClassNotFoundException: org.elasticsearch.spark.rdd.api.java.JavaEsSpark
Uhm… like some kind of difficult
Let’s go ahead with “mvn spring-boot:run” and look again after the bug-fix. Thank (^^)
Hi there!
Any help with this?
Error message: " java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.hadoop.util.Version at org.elasticsearch.hadoop.rest.RestService.createWriter(RestService.java:577) at org.elasticsearch.spark.rdd.EsRDDWriter.write(EsRDDWriter.scala:65) at org.elasticsearch.spark.rdd.EsSpark$$anonfun$doSaveToEs$1.apply(EsSpark.scala:108) at org.elasticsearch.spark.rdd.EsSpark$$anonfun$doSaveToEs$1.apply(EsSpark.scala:108) at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90) at org.apache.spark.scheduler.Task.run(Task.scala:127) at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:444) at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1377) at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:447) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)"
My code is:
Spark-submit:
This situation is very frustrated.
Hope you can help!