首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于Univocity CSV解析器的Spark java.lang.NoSuchMethodError setDelimiter方法

用于Univocity CSV解析器的Spark java.lang.NoSuchMethodError setDelimiter方法
EN

Stack Overflow用户
提问于 2019-07-29 13:47:30
回答 2查看 846关注 0票数 0

我正在尝试运行一个使用Univocity CSV解析器的Scala Spark作业,在升级到支持字符串分隔符(vs only character)后,在集群中运行jar时出现以下错误。在我的IDEA IDE中本地运行它会产生预期的结果,没有错误。

代码语言:javascript
复制
ERROR yarn.ApplicationMaster: User class threw exception: java.lang.NoSuchMethodError: com.univocity.parsers.csv.CsvFormat.setDelimiter(Ljava/lang/String;)V
java.lang.NoSuchMethodError: com.univocity.parsers.csv.CsvFormat.setDelimiter(Ljava/lang/String;)V

我尝试了以下方法:通过检查依赖关系树,消除了所有冲突的单一性解析器: mvn依赖:树-Dverbose -Dincludes=com.univocity: univocity -解析器,它产生:

代码语言:javascript
复制
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ preval ---
[INFO] dataqa:preval:jar:1.0-SNAPSHOT
[INFO] \- com.univocity:univocity-parsers:jar:2.8.2:compile

我还尝试在运行spark作业时设置spark.executor.userClassPathFirst=true配置,但行为没有任何变化。

下面是我的pom.xml中的依赖项部分:

代码语言:javascript
复制
<dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.11.12</version>
        </dependency>
        <!--
            Spark library. spark-core_2.xx must match the scala language version
        -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.11</artifactId>
            <version>2.0.0</version>
        </dependency>

        <!--
            Spark SQL library. spark-sql_2.xx must match the scala language version
        -->
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_2.11</artifactId>
            <version>2.0.0</version>
            <exclusions>
                <exclusion>  <!-- declare the exclusion here -->
                    <groupId>com.univocity</groupId>
                    <artifactId>univocity-parsers</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!--
            Library to make REST API call
        -->
        <dependency>
            <groupId>com.typesafe.play</groupId>
            <artifactId>play-ahc-ws-standalone_2.11</artifactId>
            <version>2.0.0-M1</version>
        </dependency>


        <!--
            Parses delimited files
        -->
        <dependency>
            <groupId>com.univocity</groupId>
            <artifactId>univocity-parsers</artifactId>
            <version>2.8.2</version>
            <type>jar</type>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>

我想知道Spark是否有一个内置的依赖关系,它覆盖了我的版本(2.8是第一个支持字符串参数的版本。以前,它只支持字符)。

有什么见解吗?

EN

回答 2

Stack Overflow用户

发布于 2019-08-24 20:33:41

有点晚了,但如果可以选择使用--conf spark.driver.extraClassPathspark.executor.extraClassPath,请参阅我的响应here

票数 0
EN

Stack Overflow用户

发布于 2019-08-26 23:51:11

在花了很长时间排除故障后,我找到了一个解决方案。我不得不使用这里描述的maven-shade-plugin https://www.cloudera.com/documentation/enterprise/5-13-x/topics/spark_building.html#relocation

下面是我必须添加到我的pom.xml中的maven-shade-plugin定义的相关代码部分:

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.2.1</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>

                <!-- other non-revelant filters etc omitted for brevity -->

                <relocations>
                    <!-- used to make sure there are no conflicts between the univocity parser version used here and the one that is bundled with spark -->
                    <relocation>
                        <pattern>com.univocity.parsers</pattern>
                        <shadedPattern>com.shaded.parsers</shadedPattern>
                    </relocation>
                </relocations>
            </configuration>
        </execution>
    </executions>
</plugin>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57247793

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档