"java.lang.ClassCastException" error while running scalatest through maven

162 views Asked by At

I run my test cases successfully through Intellij. But I got the "java.lang.ClassCastException" error when I run scalatest through "mvn test" command.

It's really weird. The reason might be that my scala program calls java program because some of the pure scala test cases don't have this kind of error. Does someone know how to fix this issue?


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)  ...

Also here is the part of my 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>```
0

There are 0 answers