Files
2026-07-31 15:28:08 +08:00

36 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
### 1. java.lang.ClassCastException: scala.runtime.BoxedUnit cannot be cast to java.lang.Integer
![image.png](https://myonemanager.lzybetter.repl.co/picbed_big/picbed/19d5a4c3655d4be80078beacc65cedcb.png)
1. 错误原因:在if-else语句中,对else情况没有给出结果,导致变量被赋予boxedunit类型的默认值,待满足判断条件后再想赋值正确的值就会导致类型错误
- 错误代码:
```scala
some_var = if(someCondition){
dosomething()
}
```
- 正确代码
```scala
some_var = if(someCondition){
dosomething()
}else{
default_value
}
```
### 2. java.lang.NoSuchMethodError: com.google.common.collect.Range.all()
![db38ee8654c4b8e8db1221ac8e3b5dfa.png](https://myonemanager.lzybetter.repl.co/picbed_big/picbed/653253bd7aa2574751d6b3c4b87b2b20.png)
1. 软件环境:
1. TDengine2.4.6
2. TDengine-JDBC驱动:2.0.42
3. Spark版本:2.4.0
2. 错误原因:TDengine的JDBC驱动引用了guava和failureaccess两个包与spark集群中的包版本不同,spark默认使用集群中的包,导致找不到对应的方法;
3. 解决方法:下载正确的依赖,并上传hadoop,之后在spark提交任务时引用正确版本的依赖文件,指定依赖文件的方法:
```shell
--conf spark.driver.extraClassPath=guava-30.1.1-jre.jar:failureaccess-1.0.1.jar \
--conf spark.executor.extraClassPath=guava-30.1.1-jre.jar:failureaccess-1.0.1.jar
--jars path-to-jar/guava-30.1.1- jre.jar,path-to-jar/failureaccess-1.0.1.jar
```