Error during prepare to release phase using Maven Relelase Plugin - java

I'am new in Maven and trying to perform release using maven-release-plugin.
After running mvn release:prepare i receive following info in console:
[INFO] Scanning for projects... [INFO]
[INFO]
------------------------------------------------------------------------ [INFO] Building Feeder 1.0.3-SNAPSHOT [INFO]
------------------------------------------------------------------------ [INFO] [INFO] --- maven-release-plugin:2.5.2:prepare (default-cli) #
Feeder --- [INFO] Resuming release from phase 'run-preparation-goals'
[INFO] Executing goals 'clean install'... [WARNING] Error injecting:
org.apache.maven.shared.release.exec.InvokerMavenExecutor
java.lang.NoClassDefFoundError: Lorg/apache/commons/cli/Options; at
java.lang.Class.getDeclaredFields0(Native Method) at
java.lang.Class.privateGetDeclaredFields(Class.java:2583) at
java.lang.Class.getDeclaredFields(Class.java:1916) at
com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:661)
at
com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:366)
at
com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)
at
com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:609)
at
com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:565)
at
com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:551)
at
com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:865)
at
com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:790)
at
com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:278)
at
com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:210)
at
com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:986)
at
com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1019)
at
com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:982)
at
com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1032)
at
org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
at
com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
at
com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:55)
at
com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
at
com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
at
org.eclipse.sisu.plexus.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:133)
at
com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
at
com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
at
com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
at
com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47)
at
com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at
com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1054)
at
com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:59) at
com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
at
com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:997)
at
com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1047)
at
com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:993)
at
org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82)
at
org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
at java.util.AbstractMap.get(AbstractMap.java:187) at
org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:74)
at
org.apache.maven.shared.release.phase.RunPrepareGoalsPhase.execute(RunPrepareGoalsPhase.java:44)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:234)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:169)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:146)
at
org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:107)
at
org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:286)
at
org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:240)
at
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347) at
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154) at
org.apache.maven.cli.MavenCli.execute(MavenCli.java:582) at
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) at
org.apache.maven.cli.MavenCli.main(MavenCli.java:158) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497) at
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.cli.Options at
org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at
org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at
org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at
org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
... 67 more [INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 1.578 s [INFO] Finished at:
2015-04-30T12:17:24+03:00 [INFO] Final Memory: 9M/155M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.5.2:prepare
(default-cli) on project Feeder: Execution default-cli of goal
org.apache.maven.plugins:maven-release-plugin:2.5.2:prepare failed: A
required class was missing while executing
org.apache.maven.plugins:maven-release-plugin:2.5.2:prepare:
Lorg/apache/commons/cli/Options; [ERROR]
----------------------------------------------------- [ERROR] realm = plugin>org.apache.maven.plugins:maven-release-plugin:2.5.2 [ERROR]
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] =
file:/C:/Users/Maya/.m2/repository/org/apache/maven/plugins/maven-release-plugin/2.5.2/maven-release-plugin-2.5.2.jar
[ERROR] urls[1] =
file:/C:/Users/Maya/.m2/repository/org/apache/maven/release/maven-release-manager/2.5.2/maven-release-manager-2.5.2.jar
[ERROR] urls[2] =
file:/C:/Users/Maya/.m2/repository/org/apache/maven/release/maven-release-api/2.5.2/maven-release-api-2.5.2.jar
[ERROR] urls[3] =
file:/C:/Users/Maya/.m2/repository/org/eclipse/aether/aether-util/1.0.0.v20140518/aether-util-1.0.0.v20140518.jar
[ERROR] urls[4] =
file:/C:/Users/Maya/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[5] =
file:/C:/Users/Maya/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.jar
[ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import
from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR]
-----------------------------------------------------: org.apache.commons.cli.Options [ERROR] -> [Help 1] [ERROR] [ERROR] To
see the full stack trace of the errors, re-run Maven with the -e
switch. [ERROR] Re-run Maven using the -X switch to enable full debug
logging. [ERROR] [ERROR] For more information about the errors and
possible solutions, please read the following articles: [ERROR] [Help
1]
http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
My POM file look like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mayacomp</groupId>
<artifactId>feeder</artifactId>
<version>1.0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<scm>
<developerConnection>scm:svn:http://svn01/svn/DEV/Maya/Code/feeder/tag/feeder-1.0.3</developerConnection>
<url>scm:svn:http://svn01/svn/DEV/Maya/Code/feeder/tag/feeder-1.0.3</url>
</scm>
<properties>
<java.version>1.8</java.version>
<jdk.version>1.8</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-common-artifact-filters</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<mainClass>com.mayacomp.feeder.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.mayacomp.feeder.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<tagBase>http://svn01/svn/DEV/Maya/Code/feeder/tag</tagBase>
<branchBase>http://svn01/svn/DEV/Maya/Code/feeder/branches</branchBase>
<preparationGoals>clean install</preparationGoals>
<goal>deploy</goal>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>com-mayacomp-retail-release</id>
<url>http://192.168.0.17::8080/nexus-webapp-2.11.0-02/content/repositories/com-mayacomp-retail-release</url>
</repository>
<snapshotRepository>
<id>com-mayacomp-retail-snapshot</id>
<url>http://192.168.0.17::8080/nexus-webapp-2.11.0-02/content/repositories/com-mayacomp-retail-snapshot</url>
</snapshotRepository>
</distributionManagement>
</project>
UPDATE 1:
Fixed scm element in pom:
<scm> <developerConnection>scm:svn:http://svn01/svn/DEV/Maya/Code/Feeder/trunk</developerConnection>
<url>scm:svn:http://svn01/svn/DEV/Maya/Code/Feeder/trunk</url>
</scm>

Don't define things like maven-assembly-plugin, maven-shared-utils, maven-common-artifact-filters, maven-release-plugin as dependencies. These are plugins which you don't need to define as dependencies. They are not related to your production code in any way. Furthermore you don't need to defined tagBase, branchBase and preparationGoals and goal in the maven-release-plugin configuration cause it looks like you have a default folder layout in the svn repository.
The most important part is that you need to change the scm entries to represent the trunk and NOT a tag, which is the default if you are working on a SNAPSHOT like you do.

Related

Cucumber jvm report doesnt generating

I want to get cucumber report, but it nothing generates.
I get this error during running via mvn clean install.
I cant to resolve this issue.
I'm new in automation...
/* During run as Maven Clean Install I get mentioned below error:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< MobWebAutomation:MobWebAutomation >------------------
[INFO] Building MobWebAutomation 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # MobWebAutomation ---
[INFO] Deleting C:\Users\Rauf.mirzoyev\eclipse-workspace_Appium\MobWebAutomation\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # MobWebAutomation ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # MobWebAutomation ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # MobWebAutomation ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # MobWebAutomation ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 4 source files to C:\Users\Rauf.mirzoyev\eclipse-workspace_Appium\MobWebAutomation\target\test-classes
[ERROR] /C:/Users/Rauf.mirzoyev/eclipse-workspace_Appium/MobWebAutomation/src/test/java/stepDefinitions/RegistrationWithValidCredentials.java:[116,55] unmappable character (0x8F) for encoding windows-1252
[ERROR] /C:/Users/Rauf.mirzoyev/eclipse-workspace_Appium/MobWebAutomation/src/test/java/stepDefinitions/RegistrationWithValidCredentials.java:[116,61] unmappable character (0x8F) for encoding windows-1252
[ERROR] /C:/Users/Rauf.mirzoyev/eclipse-workspace_Appium/MobWebAutomation/src/test/java/stepDefinitions/RegistrationWithValidCredentials.java:[116,64] unmappable character (0x8F) for encoding windows-1252
[INFO]
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) # MobWebAutomation ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # MobWebAutomation ---
[INFO] Building jar: C:\Users\Rauf.mirzoyev\eclipse-workspace_Appium\MobWebAutomation\target\MobWebAutomation-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-cucumber-reporting:5.0.0:generate (execution) # MobWebAutomation ---
[INFO] About to generate Cucumber report.
Dec 29, 2021 10:31:50 AM net.masterthought.cucumber.ReportBuilder generateErrorPage
INFO: Unexpected error
net.masterthought.cucumber.ValidationException: None report file was added!
at net.masterthought.cucumber.ReportParser.parseJsonFiles(ReportParser.java:62)
at net.masterthought.cucumber.ReportBuilder.generateReports(ReportBuilder.java:88)
at net.masterthought.cucumber.CucumberReportGeneratorMojo.execute(CucumberReportGeneratorMojo.java:209)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.525 s
[INFO] Finished at: 2021-12-29T10:31:51+04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.masterthought:maven-cucumber-reporting:5.0.0:generate (execution) on project MobWebAutomation: Error Found: BUILD FAILED - Check Report For Details -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the
following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
*/
/*My pom file:*/
{ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MobWebAutomation</groupId>
<artifactId>MobWebAutomation</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.2.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.0.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<includes>
<exclude>**/*Runner.java</exclude>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>MobWebAutomation</projectName>
<outputDirectory>${project.build.directory}/cucumber-reports</outputDirectory>
<enableFlashCharts>true</enableFlashCharts>
<buildNumber>42</buildNumber>
<parallelTesting>false</parallelTesting>
<inputDirectory>${project.build.directory}/cucumber-reports</inputDirectory>
<jsonFiles>
<jsonFile>**/*.json</jsonFile>
</jsonFiles>
<testFailureIgnore>true</testFailureIgnore>
<buildSuccessOnTestFailure>true</buildSuccessOnTestFailure>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
}
**Runner class**
{ package runner;
import org.junit.runner.RunWith;
import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(features = { "src/test/java/features/registration.feature" },
glue = { "stepDefinitions",
"utility" }, monochrome = true, plugin = { "pretty",
"json:target/cucumber-reports/AutomationReport.json",
"json:target/cucumber-reports/cucumber.runtime.formatter.JSONFormatter"
},
dryRun = false)//, tags = "#correct or #incorrect")
public class RunTest {
}
Thank you to all, and especially to Raghav Pal, and his YouTube channel.
After all steps, it was needed to perform "clean verify". After this operation, the report has been successfully generated.
Updated POM.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MobWebAutomation</groupId>
<artifactId>MobWebAutomation</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source> /* 1.8 it's your JDK version */
<maven.compiler.target>1.8</maven.compiler.target>/* 1.8 it's your JDK version */
</properties>
<dependencies>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.2.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>2.8.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>YOUR_PROJECT_Name</projectName>
<outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
RUNNER CLASS:
package runner;
import org.junit.runner.RunWith;
import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(
features = { "src/test/java/features/registration.feature" },
glue = { "stepDefinitions", "utility" },
monochrome = true,
plugin = {
"pretty",
"json:target/Cucumber.json"
},
dryRun = false
)
public class RunTest {
//
}
After you need to clean your project -> run via mvn clear verify. That's all.
Source: YouTube video - Selenium Cucumber Java BDD Framework 12 | How To Create HTML Reports
Following Configuration helped me to resolve the issue
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>qaclickacademy</groupId>
<artifactId>RestAPIFramework</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>RestAPIFramework</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.3.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>cucumber-jvm-example</projectName>
<jsonFiles>
<param>**/*.json</param>
</jsonFiles>
<outputDirectory>${project.build.directory}/advanced-reports</outputDirectory>
<inputDirectory>${project.build.directory}/cucumber-reports</inputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.5.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>7.5.0</version>
</dependency>
</dependencies>
</project>
TestRunner Class
#RunWith(Cucumber.class)
#CucumberOptions(features="src/test/java/features", glue= {"stepDefinations"},
monochrome = true,
plugin = {"pretty",
"json:target/cucumber-reports/reports.json",
"json:target/cucumber-reports/cucumber.runtime.formatter.JSONFormatter"})
public class TestRunner {
}

Build failing after adding a test, eventhough there are no errors in the script.Using selenium,testng with maven in eclipse

I have a maven module which has an a.b.c package and there is a test AssetUploadTest.java and one more test NavigateToPage.java. I am getting a build error only when I am adding the AssetUploadTest. I don't want the tests to run but just be compiled, because I have a properties file which has a username and pwd to my website. But due to compliance, we should not upload the username and pwd into our git. So I gave replace-with-username and replace-with-pwd.
My problem is why the build is successful when here is the second test, and why it is failing with the other test.
This is the error trace
INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.047 s
[INFO] Finished at: 2019-11-20T17:34:43-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project aem-microsoft-martech.it.tests: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\v-sruga\git\AxeCore\CSM-CASM-CoMgmt-Nabu-AEM\it.tests\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] There was an error in the forked process
[ERROR]
[ERROR] Cannot find class in classpath: com.micrososft.mcb.tests.ui.AssetUploadTest
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR]
[ERROR] Cannot find class in classpath: com.micrososft.mcb.tests.ui.AssetUploadTest
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:665)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:533)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:279)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:243)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1077)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:907)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:785)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Please help me. I tried to change the surefire version,failsafe version, but no luck.
My pom looks like this
<properties>
<junit.version>4.8.2</junit.version>
</properties>
<build>
<!-- <sourceDirectory>${basedir}/src</sourceDirectory> -->
<!-- <testSourceDirectory>${basedir}/test</testSourceDirectory> -->
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<inherited>true</inherited>
<configuration>
<instructions>
<Sling-Test-Regexp>.*Test</Sling-Test-Regexp>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>run-all-tests.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<!-- TODO create separate API package, this is just to get the special
Sling test runner -->
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.junit.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</dependency>
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
</dependency>
<dependency>
<groupId>{project.groupId}</groupId>
<artifactId>aem-microsoft-martech.core</artifactId>
<version>${project.version}</version>
<type>bundle</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
</dependencies>
</project>
No sufficient Code ,So i guess :
The class in your code is a.b.c. AssetUploadTest!
But from StackTrace we can see this line ,Cannot find class in classpath: com.micrososft.mcb.tests.ui.AssetUploadTest,which indicates that you import com.micrososft.mcb.tests.ui.AssetUploadTest in fact!
The maven can't find the class in classpath and Build failing.

Junit maven build error (maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process) [duplicate]

This question already has an answer here:
Struts 2 Junit Test case execution failed (StrutsTestCase.getActionProxy:138 ยป NullPointer)
(1 answer)
Closed 6 years ago.
I created a sample struts 2 project & J-unit test case by referring the link.
Below is my POM file.
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>au.com.woolworths</groupId>
<artifactId>struts_junit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>struts_junit Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.4</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
<version>2.3.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<finalName>struts_junit</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-toolchains-plugin
</artifactId>
<versionRange>
[1.1,)
</versionRange>
<goals>
<goal>toolchain</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.19.1</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<configuration>
<parallel>methods</parallel>
<threadCount>10</threadCount>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am able to execute the test-case successfully in eclipse, but during maven build, I am getting the below error.
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.768 s
[INFO] Finished at: 2017-02-03T11:22:46+11:00
[INFO] Final Memory: 11M/168M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project struts_junit: Execution default-test of goal org.apach
e.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
[ERROR] java.lang.NoClassDefFoundError: org/junit/runner/notification/RunListener
[ERROR] at java.lang.ClassLoader.defineClass1(Native Method)
[ERROR] at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
[ERROR] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[ERROR] at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
[ERROR] at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
[ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
[ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[ERROR] at java.lang.Class.getDeclaredConstructors0(Native Method)
[ERROR] at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
[ERROR] at java.lang.Class.getConstructor0(Class.java:3075)
[ERROR] at java.lang.Class.getConstructor(Class.java:1825)
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.getConstructor(ReflectionUtils.java:79)
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:130)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.createProviderInCurrentClassloader(ForkedBooter.java:321)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
[ERROR] Caused by: java.lang.ClassNotFoundException: org.junit.runner.notification.RunListener
[ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[ERROR] ... 22 more
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Can someone advice me why this error occurs and how to resolve this issue ?
Updating your dependency should solve this -
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
to
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
As mentioned in the Javadoc for RunListener, the class was introduced in version 4.0. Also, do make sure the same artifact is not resolved with different version transitively.

Issue with automated test not being found in classpath file

To start, let me just say that I have done quite a bit of research on my own in trying to resolve this issue. I have looked over a bunch of answers here on SO and have tried many of them but, sadly, to no avail.
My current stack is Eclipse (Mars) with Maven and Selenium. When attempting to run my automated tests, I get the following:
[INFO] Scanning for projects... [INFO] [INFO]
------------------------------------------------------------------------ [INFO] Building automation 0.0.1-SNAPSHOT [INFO]
------------------------------------------------------------------------ [WARNING] The POM for org.testng:testng:jar:5.14.3 is invalid,
transitive dependencies (if any) will not be available, enable debug
logging for more details [WARNING] The POM for
org.testng:testng:jar:5.14.4 is invalid, transitive dependencies (if
any) will not be available, enable debug logging for more details
[WARNING] The POM for org.testng:testng:jar:5.14.5 is invalid,
transitive dependencies (if any) will not be available, enable debug
logging for more details [INFO] [INFO] ---
maven-clean-plugin:2.5:clean (default-clean) # automation --- [INFO]
Deleting C:\Users\bmoore\workspace\automation\target [INFO] [INFO]
--- maven-resources-plugin:2.6:resources (default-resources) # automation --- [INFO] Using 'UTF-8' encoding to copy filtered
resources. [INFO] Copying 7 resources [INFO] [INFO] ---
maven-compiler-plugin:3.3:compile (default-compile) # automation ---
[INFO] Changes detected - recompiling the module! [INFO] Compiling 253
source files to C:\Users\bmoore\workspace\automation\target\classes
[INFO] [INFO] --- maven-resources-plugin:2.6:testResources
(default-testResources) # automation --- [INFO] Using 'UTF-8' encoding
to copy filtered resources. [INFO] Copying 3 resources [INFO] [INFO]
--- maven-compiler-plugin:3.3:testCompile (default-testCompile) # automation --- [INFO] Changes detected - recompiling the module!
[INFO] Compiling 17 source files to
C:\Users\bmoore\workspace\automation\target\test-classes [INFO]
[INFO] --- maven-surefire-plugin:2.19:test (default-test) # automation
------------------------------------------------------- T E S T S
------------------------------------------------------- Running TestSuite
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 9.679 s [INFO] Finished at:
2016-02-02T10:26:53-07:00 [INFO] Final Memory: 23M/277M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.19:test
(default-test) on project automation: Execution default-test of goal
org.apache.maven.plugins:maven-surefire-plugin:2.19:test failed: There
was an error in the forked process [ERROR] org.testng.TestNGException:
[ERROR] [ERROR] Cannot find class in classpath:
com..qa.automation.roles.SuperAdminCreateCouponTest [ERROR]
at org.testng.xml.XmlClass.loadClass(XmlClass.java:81) [ERROR] at
org.testng.xml.XmlClass.init(XmlClass.java:73) [ERROR] at
org.testng.xml.XmlClass.(XmlClass.java:59) [ERROR] at
org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:546)
[ERROR] at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
[ERROR] at
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
[ERROR] at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1344)
[ERROR] at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2787)
[ERROR] at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
[ERROR] at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
[ERROR] at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
[ERROR] at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
[ERROR] at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
[ERROR] at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
[ERROR] at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
[ERROR] at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
[ERROR] at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
[ERROR] at org.testng.xml.XMLParser.parse(XMLParser.java:38) [ERROR]
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:16) [ERROR]
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:9) [ERROR]
at org.testng.xml.Parser.parse(Parser.java:172) [ERROR] at
org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:300) [ERROR]
at org.testng.TestNG.run(TestNG.java:1021) [ERROR] at
org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:282)
[ERROR] at
org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:83)
[ERROR] at
org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:114)
[ERROR] at
org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:286)
[ERROR] at
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:240)
[ERROR] at
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
[ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of
the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven
using the -X switch to enable full debug logging. [ERROR] [ERROR] For
more information about the errors and possible solutions, please read
the following articles: [ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
That is the full trace of what happened. The issue (as I see it) is with the following lines:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test (default-test) on project automation: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test failed: There was an error in the forked process
[ERROR] org.testng.TestNGException:
[ERROR]
[ERROR] Cannot find class in classpath: com..qa.automation.roles.SuperAdminCreateCouponTest
I have tried verifying the classpath entries, and that the surefire plugin is present. In both cases, they are where they should be. I have tried committing files one-at-a-time and that works. It's only when I build that I have an issue, and it is blocking me from running the automation completely.
I am guessing that the issue is likely an easy one to resolve but, the Java/Eclipse stack is not second nature to me like .NET/C# is.
NOTE: I will update the question with new information should it become available.
UPDATE: I have included the POM below:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.kryterion.qa</groupId>
<artifactId>automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>automation</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>false</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.9</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.11.1.1</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.8</version>
</dependency>
</dependencies>
<build>
<finalName>automation</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<skipTests>${skipTests}</skipTests>
<systemPropertyVariables>
<environment>${envName}</environment>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.16</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changelog-plugin</artifactId>
<version>2.2</version>
<configuration>
<issueLinkUrl>http://prodjira01:8080/browse/%ISSUE%</issueLinkUrl>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<show>private</show>
<additionalparam>${javadoc.doclint.none}</additionalparam>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.4</version>
<configuration>
<linkXRef>true</linkXRef>
<source>1.8</source>
<targetJdk>1.8</targetJdk>
<rulesets>
<ruleset>/rulesets/java/basic.xml</ruleset>
<ruleset>/rulesets/java/braces.xml</ruleset>
<ruleset>/rulesets/java/design.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
<version>2.4</version>
<configuration>
<tagListOptions>
<tagClasses>
<tagClass>
<displayName>Todo</displayName>
<tags>
<tag>
<matchString>todo</matchString>
<matchType>ignoreCase</matchType>
</tag>
<tag>
<matchString>FIXME</matchString>
<matchType>ignoreCase</matchType>
</tag>
<tag>
<matchString>NB</matchString>
<matchType>exact</matchType>
</tag>
</tags>
</tagClass>
<tagClass>
<displayName>Deprecated</displayName>
<tags>
<tag>
<matchString>#deprecated</matchString>
<matchType>ignoreCase</matchType>
</tag>
</tags>
</tagClass>
</tagClasses>
</tagListOptions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<xmlOutput>true</xmlOutput>
<!-- Optional directory to put findbugs xdoc xml report -->
<xmlOutputDirectory>target/site</xmlOutputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>config/sun_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
#sircapsalot - I made the change you suggested below and what happened is that all of the:
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
Suddenly started throwing warnings in all the classes that had those imports. Thoughts?
According to Maven Central, the version you are requesting isn't there. (you are requesting org.testng:testng:jar:5.14.3)
Try updating to the newest version: 6.9.10 in your pom.xml
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
So, I figured out the issue... It turns out, it was a problem with PEBKAC.
I renamed a file that I had changed yesterday back to its original state and all is well now. Thanks for those that chimed in to help with this!

Maven: Cannot Find Symbol

I am attempting to run Maven builds of a Java project, however tests are failing stating that the Player symbol cannot be founded, despite being imported.
Maven builds are failing as follows:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[4,31] error: cannot find symbol
[ERROR] package com.ffxivcensus.gatherer
/var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[22,8] error: cannot find symbol
[ERROR] class PlayerTest
/var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[22,27] error: cannot find symbol
[ERROR] class PlayerTest
/var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[116,12] error: cannot find symbol
[ERROR] class PlayerTest
/var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[116,28] error: cannot find symbol
[INFO] 5 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.415 s
[INFO] Finished at: 2016-01-18T15:35:38+01:00
[INFO] Final Memory: 18M/206M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project XIVStats-Gatherer-Java: Compilation failure: Compilation failure:
[ERROR] /var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[4,31] error: cannot find symbol
[ERROR] package com.ffxivcensus.gatherer
[ERROR] /var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[22,8] error: cannot find symbol
[ERROR] class PlayerTest
[ERROR] /var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[22,27] error: cannot find symbol
[ERROR] class PlayerTest
[ERROR] /var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[116,12] error: cannot find symbol
[ERROR] class PlayerTest
[ERROR] /var/lib/jenkins/workspace/XIVStats-Gatherer-Java/src/test/com/ffxivcensus/gatherer/PlayerTest.java:[116,28] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
My config is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ffxivcensus.gatherer</groupId>
<artifactId>XIVStats-Gatherer-Java</artifactId>
<version>1.0pre</version>
<name>XIVStats Lodestone Gatherer</name>
<url>https://github.com/xivstats</url>
<licenses>
<license>
<name>BSD 2-Clause License</name>
<url>https://opensource.org/licenses/BSD-2-Clause</url>
<distribution>repo</distribution>
</license>
</licenses>
<issueManagement>
<url>https://github.com/XIVStats/XIVStats-Gatherer-Java/issues</url>
<system>GitHub Issues</system>
</issueManagement>
<developers>
<developer>
<email>me#example.com</email>
<name>Peter Reid</name>
<url>https://github.com/reidweb</url>
<id>reidweb</id>
</developer>
<developer>
<email>me#example.com</email>
<name>Jonathan Price</name>
<url>https://github.com/pricetx</url>
<id>pricetx</id>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>mvnrepository.com</id>
<name>mvnrepository.com</name>
<url>http://mvnrepository.com/</url>
</repository>
</repositories>
<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<testOutputDirectory>target/test</testOutputDirectory>
<sourceDirectory>src/main</sourceDirectory>
<testSourceDirectory>src/test/</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<includes>
<include>src</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>com.ffxivcensus.gatherer.GathererController</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1207</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
See this github project
In your Maven-compiler-plugin definition:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<includes>
<include>src</include>
</includes>
</configuration>
</plugin>
Do not include the src folder directly. It will mess up the compilation order, Maven ends up building the test folder first, then fails on missing the main classes. Change it to this to make it work:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
</plugin>

Categories