I'm getting the following error in my POM file:
POM file:
Error:
I tried to transfer my cucumber project to another machine, but the only warning to pop up was Invalid Plugin configuration :Test Error Ignore.
I've researched this issue but cannot find anything related.
I found the answer it was visible all this time:
instead of
<suiteXmlFiles>
<!-- <suiteXmlFile>testng.xml</suiteXmlFile> -->
</suiteXmlFiles>
<testErrorIgnore>false</testErrorIgnore>
<testFailureIgnore>false</testFailureIgnore>
it should have been:
<!-- <suiteXmlFile>testng.xml</suiteXmlFile> -->
<suiteXmlFiles>
<testErrorIgnore>false</testErrorIgnore>
<testFailureIgnore>false</testFailureIgnore>
'</suiteXmlFiles>'
My oversight.
Related
I got this error while running a junit-test in my application. Which I later found out because of declared field size
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:899)
at java.util.TimSort.mergeAt(TimSort.java:516)
at java.util.TimSort.mergeCollapse(TimSort.java:441)
...
org.mockito.internal.configuration.injection.PropertyAndSetterInjection.orderedInstanceFieldsFrom(PropertyAndSetterInjection.java:125)
I found that probable solution would be adding this flag.
-Djava.util.Arrays.useLegacyMergeSort=true in VM args. But I wanted to add in pom.xml
I referred to this how to add VM args using pom xml but it refers mostly for -X flags, what would be an appropriate placement in here?
I updated the pom.xml with the surefire plugin and used argLine parameter as suggested here
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>-Djava.util.Arrays.useLegacyMergeSort=true</argLine>
</configuration>
</plugin>
Trere are 2 ways to configure [System Properties in surefire plugin] (https://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html)
Option 1: systemPropertyVariables
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<systemPropertyVariables>
<java.util.Arrays.useLegacyMergeSort>true</java.util.Arrays.useLegacyMergeSort>
</systemPropertyVariables>
</configuration>
</plugin>
Option 2: argLine
Some system properties must be set on the command line of the forked VM, and cannot be set after the VM has been started. These properties must be added to the argLine parameter of the Surefire plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>-Djava.util.Arrays.useLegacyMergeSort=true</argLine>
</configuration>
</plugin>
Upgrade your dependencies
On the other hand, I really think that the right solution is to upgrade Mockito to 2.1 or later
2.1 was released in October, 2016, and contains the fix to your issue: Make PropertyAndSetterInjection field sorting consistent #176
I'm trying to get Maven surefire to run under JDK 11 but I keep getting these errors:
If I set reuseForks to true:
Error occurred in starting fork, check output in log
Process Exit Code: 1
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:670)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:283)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:246)
If I set it to false:
Execution default-test of goal org.apache.maven.plugins:maven-surefire- plugin:3.0.0-M1:test
failed: java.lang.ClassNotFoundException: org.apache.maven.plugin.surefire.StartupReportConfiguration
I've found this and this link that describe the same problem but they don't have any solution.
For replication of this bug I created this git repo
Seems like while using a modular project to test, you need to have forkCount set as 0 :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<forkCount>0</forkCount> <!-- changed this to 0 -->
<reuseForks>false</reuseForks>
<!-- <threadCount>1</threadCount> --> <!-- shall be used with 'parallel' -->
<printSummary>true</printSummary>
<!-- <skipTests>false</skipTests> --> <!-- defaults to false -->
<!-- run test in headless mode -->
<systemPropertyVariables>
<glass.platform>Monocle</glass.platform>
<monocle.platform>Headless</monocle.platform>
<prism.order>d3d</prism.order>
</systemPropertyVariables>
<argLine>
--add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
Quoting from this article
When module-info.java is present and fork process is enabled, surefire
creates a mixed classpath with modules and unnamed modules causing
module visibility issues and preventing the application to start.
Note: Disabling the forkCount and reuseForks configuration parameters, results in org.apache.maven.surefire.booter.SurefireBooterForkException being thrown, similar to the one reported in SUREFIRE-1528.
If this could help the developers at Maven community, the execution dump from the same run reads the following:
# Created at 2018-11-23T09:31:53.631
Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream 'Error occurred during initialization of boot layer'.
java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command 'Error occurred during initialization of boot layer'.
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.<init>(ForkClient.java:507)
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:210)
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:177)
at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88)
at java.base/java.lang.Thread.run(Thread.java:834)
Here is the line of code in the source repository.
I found the solution here:
https://winterbe.com/posts/2018/08/29/migrate-maven-projects-to-java-11-jigsaw/
I had to add.
<argLine>
--illegal-access=permit
</argLine>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
Here is my pom.xml code. While debugging as TestNG getting
"Reference to undefined variable surefireArgLine"
Googled and tried some solutions. By removing below line,
${surefireArgLine}
getting below error
"Error: Could not find or load main class argLine"
still facing issue.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>suite.xml</suiteXmlFile>
</suiteXmlFiles>
<useSystemClassLoader>false</useSystemClassLoader>
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
<plugin>
It worked for me after unchecking the checkbox near argLine in
Window->Preferences->TestNG->Maven.
0
It worked for me after unchecking all of the checkboxes near argLine in Window->Preferences->TestNG->Maven. and then, finally, click on Apply and OK.
I'm trying to add a JSP ruleset to an existing Maven build using PMD. Unfortunately, it seems like no matter what I do I get an error. If I add the reference to our existing ruleset:
<rule ref="rulesets/jsp/basic.xml/NoUnsanitizedJSPExpression" />
I get this message (linebreaks added for readability:
Execution DRY of goal org.apache.maven.plugins:maven-pmd-plugin:2.7.1:pmd failed:
Couldn't find that class Can't find resource rulesets/jsp/basic.xml.
Make sure the resource is a valid file or URL or is on the CLASSPATH -> [Help 1]
I've consulted this question and tried various permutations of leading slashes:
<rule ref="/rulesets/jsp/basic.xml/NoUnsanitizedJSPExpression" />
but I still get the error message referenced above.
I've tried adding the ruleset to the Maven plugin (second ruleset):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<rulesets>
<ruleset>${project.basedir}/src/main/resources/properties/pmd_workspace.xml</ruleset>
<ruleset>rulesets/jsp/basic.xml</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<id>DRY</id>
<phase>test</phase>
<goals>
<goal>cpd</goal>
<goal>pmd</goal>
</goals>
</execution>
</executions>
</plugin>
but that simply gives me this error:
An error has occurred in PMD Report report generation. Could not find resource 'rulesets/jsp/basic.xml'. -> [Help 1]
I've looked at the documentation for PMD and for the Maven PMD plugin but had no luck. Can anyone help or point me to a tutorial?
This turned out be because I was using an old version of the Maven PMD plugin. The Maven plugin pulls in PMD by itself, which is convenient, but doesn't give you any control over what version it pulls in.
The version I was using, 2.7.1, pulled in PMD version 4.3, which did not have the rule I was trying to include. Therefore, it (correctly) stated that it couldn't find that rule.
The current version of the Maven PMD plugin, 3.3, pulls in PMD version 5.2.1, which does include the NoUnsanitizedJSPExpression JSP-checking rule.
Once I updated the maven PMD plugin to version 3.3, everything worked:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.3</version>
<configuration>
<rulesets>
<ruleset>${project.basedir}/src/main/resources/properties/pmd_workspace.xml</ruleset>
</rulesets>
</configuration>
</plugin>
When building WAR package using Maven 2.1.1, I get this warning message:
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ig
nored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specifi
ed as 'true')
Is there a way to eliminate it? It doesn't fail the building process, but I just do not want to see it.
It seems to be fixed in current version of maven-war-plugin, so just specifying:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
fixed it for me. (See the last answer (20/Sep/12 4:37 AM) from Anders Hammar on https://issues.apache.org/jira/browse/MWAR-248.)
I got rid of this warning in maven 3.0.1 with the following build configuration (i believe perhaps web.xml is added to the project by other means, and should't be packaged by default):
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
I've filed the following bug report regarding this issue: https://issues.apache.org/jira/browse/MWAR-248