sortpom: PowerMock/Mockito Tests are failing after Sorting pom.xml

Hello, After sorting my pom.xml suddenly the tests are not running anymore. after reverting the pom.xml, it works again.

<plugin>
                    <groupId>com.github.ekryd.sortpom</groupId>
                    <artifactId>sortpom-maven-plugin</artifactId>
                    <version>${version.sortpom-maven-plugin}</version>
                    <configuration>
                        <predefinedSortOrder>recommended_2008_06</predefinedSortOrder>
                        <keepBlankLines>true</keepBlankLines>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <sortDependencies>scope,artifactId</sortDependencies>
                        <sortPlugins>groupId,artifactId</sortPlugins>
                        <sortProperties>false</sortProperties>
                        <sortModules>true</sortModules>
                        <createBackupFile>false</createBackupFile>
                        <ignoreLineSeparators>false</ignoreLineSeparators>
                        <nrOfIndentSpace>4</nrOfIndentSpace>
                        <indentBlankLines>false</indentBlankLines>
                    </configuration>
                </plugin>
java.lang.ExceptionInInitializerError
        at my.project.pkg.esb.dispatch.MessageDispatcherTest.setUp(MessageDispatcherTest.java:102)
Caused by: java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.StackTraceCleanerProvider (alternate: null)
        at my.project.pkg.esb.dispatch.MessageDispatcherTest.setUp(MessageDispatcherTest.java:102)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.StackTraceCleanerProvider implementation declared in java.lang.CompoundEnumeration@47cb2624
        at my.project.pkg.esb.dispatch.MessageDispatcherTest.setUp(MessageDispatcherTest.java:102)
Caused by: java.lang.ClassCastException: **Cannot cast org.powermock.api.mockito.internal.exceptions.StackTraceCleanerProvider to org.mockito.plugins.StackTraceCleanerProvider**
        at my.project.pkg.esb.dispatch.MessageDispatcherTest.setUp(MessageDispatcherTest.java:102)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I have been using SortPom together with Jenkins, but then I use the verify goal instead. Each developer must sort the pom (often just by building the project) before they make a checkin.

The verify goal will fail the build if the pom is not sorted, same as it fails the build if tests are not successful.

So the Jenkins server will never sort the pom

thanks for the advices and hints. i’m getting rid of easymock. that is the best way. ticket can be closed.

other Question: what is your experience with sortpom-plugin plus Jenkins CI. Currently i have to tell my Jenkins-Job to clean checkout from SVN, otherwise there will be always an merge conflict in pom.xml when run the job the second time.

Hi, There are three settings that affect the actual build:

  • sortDependencies may affect in which order classes are added to the build if a library is included multiple times. This may happen i a library is included both directly and indirectly in the pom.

  • sortPlugins may affect in which order Maven plugins are run in a build. This may happen if multiple plugins are run in the same Maven phase.

  • sortModules may cause a build to fail if the modules are indirectly referencing each other.

Use the same SortPom configuration as before and remove the sortDependencies, sortPlugins and sortModules parameter. The build should now run fine. Add parameters back to the SortPom configuration one by one to see which one causes the build error.

When the guilty parameter has been identified, I can help you solve the actual problem.