“java.lang.classcastexception”在通过maven运行scalatest时出错

hk8txs48  于 2021-05-24  发布在  Spark
关注(0)|答案(0)|浏览(371)

我通过intellij成功地运行了我的测试用例。但是当我通过“mvn test”命令运行scalatest时,出现了“java.lang.classcastexception”错误。
真的很奇怪。原因可能是我的scala程序调用java程序,因为一些纯scala测试用例没有这种错误。有人知道如何解决这个问题吗?

Cause: java.lang.ClassCastException: cannot assign instance of scala.collection.immutable.List$SerializationProxy to field org.apache.spark.rdd.RDD.org$apache$spark$rdd$RDD$$dependencies_ of type scala.collection.Seq in instance of org.apache.spark.rdd.MapPartitionsRDD   at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2287) at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1417) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2293) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2211)  at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2069) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1573)  at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2287) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2211)  at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2069) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1573)  ...

这里还有pom.xml的一部分

<pluginManagement>
           <plugins>
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-surefire-plugin</artifactId>
                   <version>2.7</version>
               </plugin>
               <plugin>
                   <groupId>org.scalatest</groupId>
                   <artifactId>scalatest-maven-plugin</artifactId>
                   <version>1.0</version>
               </plugin>
           </plugins>
       </pluginManagement>
       <plugins>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>
               <configuration>
                   <skipTests>true</skipTests>
               </configuration>
           </plugin>
           <plugin>
               <groupId>org.scalatest</groupId>
               <artifactId>scalatest-maven-plugin</artifactId>
               <configuration>
                   <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                   <junitxml>.</junitxml>
                   <filereports>WDF TestSuite.txt</filereports>
               </configuration>
               <executions>
                   <execution>
                       <id>test</id>
                       <goals>
                           <goal>test</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
           <plugin>
               <groupId>net.alchim31.maven</groupId>
               <artifactId>scala-maven-plugin</artifactId>
               <executions>
                   <execution>
                       <goals>
                           <goal>compile</goal>
                           <goal>testCompile</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-resources-plugin</artifactId>
           </plugin>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-shade-plugin</artifactId>
               <configuration>
                   <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
                   <createDependencyReducedPom>true</createDependencyReducedPom>
                   <filters>
                       <filter>
                           <artifact>*:*</artifact>
                           <excludes>
                               <exclude>META-INF/*.SF</exclude>
                               <exclude>META-INF/*.DSA</exclude>
                               <exclude>META-INF/*.RSA</exclude>
                           </excludes>
                       </filter>
                   </filters>
               </configuration>
               <executions>
                   <execution>
                       <phase>package</phase>
                       <goals>
                           <goal>shade</goal>
                       </goals>

                   </execution>
               </executions>
           </plugin>
           <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <executions>
                   <execution>
                       <id>log4j-plugin-processor</id>
                       <goals>
                           <goal>compile</goal>
                       </goals>
                       <phase>process-classes</phase>
                       <configuration>
                           <proc>only</proc>
                           <annotationProcessors>
                               <annotationProcessor>
                                   org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor
                               </annotationProcessor>
                           </annotationProcessors>
                           <source>8</source>
                           <target>8</target>
                       </configuration>
                   </execution>
               </executions>
           </plugin>
       </plugins>
   </build>```

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题