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

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

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

  1. 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的一部分

  1. <pluginManagement>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.apache.maven.plugins</groupId>
  5. <artifactId>maven-surefire-plugin</artifactId>
  6. <version>2.7</version>
  7. </plugin>
  8. <plugin>
  9. <groupId>org.scalatest</groupId>
  10. <artifactId>scalatest-maven-plugin</artifactId>
  11. <version>1.0</version>
  12. </plugin>
  13. </plugins>
  14. </pluginManagement>
  15. <plugins>
  16. <plugin>
  17. <groupId>org.apache.maven.plugins</groupId>
  18. <artifactId>maven-surefire-plugin</artifactId>
  19. <configuration>
  20. <skipTests>true</skipTests>
  21. </configuration>
  22. </plugin>
  23. <plugin>
  24. <groupId>org.scalatest</groupId>
  25. <artifactId>scalatest-maven-plugin</artifactId>
  26. <configuration>
  27. <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
  28. <junitxml>.</junitxml>
  29. <filereports>WDF TestSuite.txt</filereports>
  30. </configuration>
  31. <executions>
  32. <execution>
  33. <id>test</id>
  34. <goals>
  35. <goal>test</goal>
  36. </goals>
  37. </execution>
  38. </executions>
  39. </plugin>
  40. <plugin>
  41. <groupId>net.alchim31.maven</groupId>
  42. <artifactId>scala-maven-plugin</artifactId>
  43. <executions>
  44. <execution>
  45. <goals>
  46. <goal>compile</goal>
  47. <goal>testCompile</goal>
  48. </goals>
  49. </execution>
  50. </executions>
  51. </plugin>
  52. <plugin>
  53. <groupId>org.apache.maven.plugins</groupId>
  54. <artifactId>maven-resources-plugin</artifactId>
  55. </plugin>
  56. <plugin>
  57. <groupId>org.apache.maven.plugins</groupId>
  58. <artifactId>maven-shade-plugin</artifactId>
  59. <configuration>
  60. <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
  61. <createDependencyReducedPom>true</createDependencyReducedPom>
  62. <filters>
  63. <filter>
  64. <artifact>*:*</artifact>
  65. <excludes>
  66. <exclude>META-INF/*.SF</exclude>
  67. <exclude>META-INF/*.DSA</exclude>
  68. <exclude>META-INF/*.RSA</exclude>
  69. </excludes>
  70. </filter>
  71. </filters>
  72. </configuration>
  73. <executions>
  74. <execution>
  75. <phase>package</phase>
  76. <goals>
  77. <goal>shade</goal>
  78. </goals>
  79. </execution>
  80. </executions>
  81. </plugin>
  82. <plugin>
  83. <groupId>org.apache.maven.plugins</groupId>
  84. <artifactId>maven-compiler-plugin</artifactId>
  85. <executions>
  86. <execution>
  87. <id>log4j-plugin-processor</id>
  88. <goals>
  89. <goal>compile</goal>
  90. </goals>
  91. <phase>process-classes</phase>
  92. <configuration>
  93. <proc>only</proc>
  94. <annotationProcessors>
  95. <annotationProcessor>
  96. org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor
  97. </annotationProcessor>
  98. </annotationProcessors>
  99. <source>8</source>
  100. <target>8</target>
  101. </configuration>
  102. </execution>
  103. </executions>
  104. </plugin>
  105. </plugins>
  106. </build>```

暂无答案!

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

相关问题