JBehave throwing NullPointerException when running embeddable stories - java
I am working on a Spring MVC rest service, for which I am also trying to set up JBehave. This is a Maven project with a single module, and the JBehave code is living under the test scope of that module. My problem is that my sample test (which is just an empty test) is failing with an NPE. I was expecting to see the test pass so that I know JBehave is set up properly. Can you take a look at what I've got and see if you can help me spot what is causing the NPE?
First, relevant parts of my maven configuration:
<properties>
<jbehave.version>4.0.4</jbehave.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>${jbehave.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-spring</artifactId>
<version>${jbehave.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbehave.site</groupId>
<artifactId>jbehave-site-resources</artifactId>
<version>3.1.1</version>
<scope>test</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>${jbehave.version}</version>
<classifier>resources</classifier>
<type>zip</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<scope>test</scope>
<testSourceDirectory>${basedir}/src/test/java/</testSourceDirectory>
<testClassesDirectory>${project.build.directory}/test-classes/</testClassesDirectory>
<includes>
<include>com/mycompany/myproject/test/behavior/steps/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>${jbehave.version}</version>
<configuration>
<scope>test</scope>
</configuration>
<executions>
<execution>
<id>unpack-view-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-view-resources</goal>
</goals>
</execution>
<execution>
<id>run-stories-as-embeddables</id>
<phase>integration-test</phase>
<configuration>
<scope>test</scope>
<includes>
<include>com/mycompany/myproject/test/behavior/steps/*.java</include>
</includes>
<systemProperties>
<property>
<name>java.awt.headless</name>
<value>true</value>
</property>
</systemProperties>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
</build>
I run my tests via mvn clean integration-test -e and I get this output:
$ mvn clean integration-test -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject 0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # MyProject ---
[INFO] Deleting C:\Users\mylogin\myproject\target
[INFO]
[INFO] --- jbehave-maven-plugin:4.0.4:unpack-view-resources (unpack-view-resources) # MyProject ---
[INFO] Unpacked C:\Users\mylogin\.m2\repository\org\jbehave\site\jbehave-site-resources\3.1.1\jbehave-site-resources-3.1.1.zip to C:\Users\mylogin\myproject\target\jbehave\view
[INFO] Unpacked C:\Users\mylogin\.m2\repository\org\jbehave\jbehave-core\4.0.4\jbehave-core-4.0.4-resources.zip to C:\Users\mylogin\myproject\target\jbehave\view
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # MyProject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 18 resources
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # MyProject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 62 source files to C:\Users\mylogin\myproject\target\classes
... omitted ...
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # MyProject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # MyProject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 12 source files to C:\Users\mylogin\myproject\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) # MyProject ---
[INFO] Surefire report directory: C:\Users\mylogin\myproject\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps
Processing system properties {}
Using controls EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=false,verboseFailures=true,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]
Running story com/mycompany/myproject/test/behavior/steps/sample_rest_call_with_invalid_account_steps.story
Generating reports view to 'C:\Users\mylogin\myproject\target\jbehave' using formats '[stats, ide_console, txt, html]' and view properties '{navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, reports=ftl/jbehave-reports.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl, decorated=ftl/jbehave-report-decorated.ftl, maps=ftl/jbehave-maps.ftl}'
Reports view generated with 2 stories (of which 1 pending) containing 1 scenarios (of which 1 pending)
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.326 sec - in com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:3.0.0:war (default-war) # MyProject ---
[INFO] Packaging webapp
[INFO] Assembling webapp [MyProject] in [C:\Users\mylogin\myproject\target\mywarname##0.1]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\mylogin\myproject\src\main\webapp]
[INFO] Webapp assembled in [484 msecs]
[INFO] Building war: C:\Users\mylogin\myproject\target\mywarname##0.1.war
[INFO]
[INFO] --- spring-boot-maven-plugin:1.3.5.RELEASE:repackage (default) # MyProject ---
[INFO]
[INFO] --- jbehave-maven-plugin:4.0.4:run-stories-as-embeddables (run-stories-as-embeddables) # MyProject ---
[INFO] Running stories as embeddables using embedder Embedder[storyMapper=StoryMapper,embedderMonitor=MavenEmbedderMonitor,classLoader=EmbedderClassLoader[urls=[/C:/Users/mylogin/Projects/AQ/aqservices/target/test-classes/, /C:/Users/mylogin/Projects/AQ/aqservices/target/classes/, spring-boot-starter-tomcat-1.3.5.RELEASE.jar, tomcat-embed-core-8.0.33.jar, tomcat-embed-el-8.0.33.jar, tomcat-embed-logging-juli-8.0.33.jar, tomcat-embed-websocket-8.0.33.jar, spring-ws-core-2.3.0.RELEASE.jar, spring-xml-2.3.0.RELEASE.jar, spring-aop-4.2.6.RELEASE.jar, spring-beans-4.2.6.RELEASE.jar, spring-core-4.2.6.RELEASE.jar, spring-oxm-4.2.6.RELEASE.jar, spring-web-4.2.6.RELEASE.jar, spring-webmvc-4.2.6.RELEASE.jar, spring-boot-starter-1.3.5.RELEASE.jar, spring-boot-1.3.5.RELEASE.jar, spring-boot-autoconfigure-1.3.5.RELEASE.jar, snakeyaml-1.16.jar, spring-boot-starter-log4j-1.3.7.RELEASE.jar, jcl-over-slf4j-1.7.21.jar, jul-to-slf4j-1.7.21.jar, slf4j-log4j12-1.7.21.jar, log4j-1.2.17.jar, spring-orm-4.3.2.RELEASE.jar, spring-jdbc-4.2.6.RELEASE.jar, spring-tx-4.2.6.RELEASE.jar, spring-data-commons-1.12.2.RELEASE.jar, spring-context-4.2.6.RELEASE.jar, spring-expression-4.2.6.RELEASE.jar, spring-context-support-4.1.4.RELEASE.jar, spring-test-4.2.6.RELEASE.jar, spring-security-core-4.1.1.RELEASE.jar, aopalliance-1.0.jar, spring-security-web-4.1.1.RELEASE.jar, spring-security-config-4.1.1.RELEASE.jar, jstl-1.2.jar, wsdl4j-1.6.3.jar, aspectjweaver-1.8.9.jar, jasypt-1.9.2.jar, xstream-1.4.9.jar, xmlpull-1.1.3.1.jar, xpp3_min-1.1.4c.jar, bcprov-jdk16-1.46.jar, org.apache.commons.io-2.4.jar, commons-io-2.4.jar, slf4j-api-1.7.21.jar, commons-lang-2.6.jar, mail-1.4.jar, activation-1.1.jar, dozer-5.5.1.jar, commons-beanutils-1.9.2.jar, commons-lang3-3.2.1.jar, jregex-1.2_01.jar, tomcat-embed-jasper-8.0.33.jar, ecj-4.5.jar, ehcache-2.10.2.2.21.jar, HikariCP-2.4.7.jar, emdq-1.0.jar, sqljdbc4-4.0.jar, ghs-verifyaq-client-1.0.3.jar, mockito-all-1.9.5.jar, junit-4.11.jar, hamcrest-core-1.3.jar, jbehave-core-4.0.4.jar, hamcrest-library-1.3.jar, hamcrest-integration-1.3.jar, commons-collections-3.2.2.jar, plexus-utils-3.0.10.jar, freemarker-2.3.23.jar, paranamer-2.4.jar, jbehave-spring-4.0.4.jar],parent=ClassRealm[plugin>org.jbehave:jbehave-maven-plugin:4.0.4, parent: sun.misc.Launcher$AppClassLoader#55f96302]],embedderControls=UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]],embedderFailureStrategy=<null>,configuration=org.jbehave.core.configuration.MostUsefulConfiguration#645b2ac7,candidateSteps=<null>,stepsFactory=<null>,metaFilters=<null>,metaMatchers=<null>,systemProperties={java.awt.headless=true},executorService=<null>,executorServiceCreated=false,performableTree=PerformableTree,storyManager=<null>,timeoutParsers=<null>]
[INFO] Found class names: [com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps]
[INFO] Using controls UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]]
[INFO] Running embeddable com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps
[INFO] Processing system properties {java.awt.headless=true}
[INFO] System property 'java.awt.headless' set to 'true'
[INFO] Using controls UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeouts=300,threads=1,failOnStoryTimeout=false]]
[INFO] Generating reports view to 'C:\Users\mylogin\myproject\target\jbehave' using formats '[stats, ide_console, txt, html]' and view properties '{navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, reports=ftl/jbehave-reports.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl, decorated=ftl/jbehave-report-decorated.ftl, maps=ftl/jbehave-maps.ftl}'
[INFO] Reports view generated with 2 stories (of which 1 pending) containing 1 scenarios (of which 1 pending)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.714 s
[INFO] Finished at: 2017-03-28T13:25:28-04:00
[INFO] Final Memory: 38M/299M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:4.0.4:run-stories-as-embeddables (run-stories-as-embeddables) on project MyProject: Failed to run stories as embeddables: Failure in running embeddable: com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jbehave:jbehave-maven-plugin:4.0.4:run-stories-as-embeddables (run-stories-as-embeddables) on project MyProject: Failed to run stories as embeddables
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:498)
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: org.apache.maven.plugin.MojoFailureException: Failed to run stories as embeddables
at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:20)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: org.jbehave.core.embedder.Embedder$RunningEmbeddablesFailed: Failure in running embeddable: com.mycompany.myproject.test.behavior.steps.SampleRestCallWithInvalidAccountSteps
at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:140)
at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:18)
... 22 more
Caused by: java.lang.NullPointerException
at org.jbehave.core.steps.spring.SpringStepsFactory.stepsTypes(SpringStepsFactory.java:39)
at org.jbehave.core.steps.AbstractStepsFactory.createCandidateSteps(AbstractStepsFactory.java:34)
at org.jbehave.core.embedder.PerformableTree$RunContext.<init>(PerformableTree.java:458)
at org.jbehave.core.embedder.PerformableTree.newRunContext(PerformableTree.java:1105)
at org.jbehave.core.embedder.StoryManager.runStories(StoryManager.java:100)
at org.jbehave.core.embedder.StoryManager.runStoriesAsPaths(StoryManager.java:86)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:213)
at org.jbehave.core.junit.JUnitStory.run(JUnitStory.java:24)
at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:131)
... 23 more
[ERROR]
[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 story file, named sample_rest_call_with_invalid_account_steps.story:
Scenario: Call the sample rest resource
Given an initial value
When this API is called
Then expect failure
My java story class, named SampleRestCallWithInvalidAccountSteps.java:
import com.mycompany.myproject.test.behavior.driver.AbstractSpringJBehaveStory;
import com.mycompany.myproject.test.behavior.driver.annotations.BehaviorTest;
import org.jbehave.core.annotations.*;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Scenario: Call the sample rest resource
*/
#RunWith(SpringJUnit4ClassRunner.class)
#BehaviorTest
public class SampleRestCallWithInvalidAccountSteps extends AbstractSpringJBehaveStory {
#Given("an initial value")
public void Given() {
// purposely empty
}
#When("this API is called")
public void When() {
// purposely empty
}
#Then("expect failure")
public void Then() {
// purposely empty
}
}
My story superclass:
package com.mycompany.myproject.test.behavior.driver;
import java.util.Arrays;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.embedder.Embedder;
import org.jbehave.core.embedder.EmbedderControls;
import org.jbehave.core.io.CodeLocations;
import org.jbehave.core.io.LoadFromClasspath;
import org.jbehave.core.io.StoryLoader;
import org.jbehave.core.io.StoryPathResolver;
import org.jbehave.core.io.UnderscoredCamelCaseResolver;
import org.jbehave.core.junit.JUnitStory;
import org.jbehave.core.reporters.FilePrintStreamFactory;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.ParameterControls;
import org.jbehave.core.steps.spring.SpringStepsFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
public abstract class AbstractSpringJBehaveStory extends JUnitStory {
#Autowired
private ApplicationContext appContext;
public AbstractSpringJBehaveStory() {
Embedder embedder = new Embedder();
embedder.useEmbedderControls(embedderControls());
embedder.useMetaFilters(Arrays.asList("-skip"));
useEmbedder(embedder);
}
#Override
public InjectableStepsFactory stepsFactory() {
return new SpringStepsFactory(configuration(), appContext);
}
#Override
public Configuration configuration() {
return new MostUsefulConfiguration()
.useStoryPathResolver(storyPathResolver())
.useStoryLoader(storyLoader())
.useStoryReporterBuilder(storyReporterBuilder())
.useParameterControls(parameterControls());
}
private EmbedderControls embedderControls() {
return new EmbedderControls()
.doIgnoreFailureInStories(true)
.doGenerateViewAfterStories(true)
.doVerboseFailures(true);
}
private StoryPathResolver storyPathResolver() {
return new UnderscoredCamelCaseResolver();
}
private StoryLoader storyLoader() {
return new LoadFromClasspath();
}
private StoryReporterBuilder storyReporterBuilder() {
return new StoryReporterBuilder()
.withCodeLocation(CodeLocations.codeLocationFromClass(this.getClass()))
.withPathResolver(new FilePrintStreamFactory.ResolveToPackagedName())
.withFailureTrace(true)
.withDefaultFormats()
.withFormats(Format.IDE_CONSOLE, Format.TXT, Format.HTML);
}
private ParameterControls parameterControls() {
return new ParameterControls()
.useDelimiterNamedParameters(true);
}
}
For reference, I was loosely following this guide.
I now have a working solution. I believe that I have narrowed the culprit to improperly extending AbstractSpringJBehaveStory in the SampleRestCallSteps class. I fixed this by creating a new empty class to serve as an instantiable subclass of AbstractSpringJBehaveStory and removing the extends from SampleRestCallSteps.
Also, I did find a few missing lines when creating the Configuration, which I believe is the real cause. I got the new ones that are now shown in the method below from generating a blank new JBehave-Spring archetype with maven.
#Override
public Configuration configuration() {
ParameterConverters parameterConverters = new ParameterConverters();
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(
new LocalizedKeywords(),
new LoadFromClasspath(this.getClass()),
parameterConverters);
parameterConverters.addConverters(
new DateConverter(new SimpleDateFormat("yyyy-MM-dd")),
new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration()
.useStoryLoader(storyLoader())
.useStoryParser(new RegexStoryParser(examplesTableFactory))
.useStoryReporterBuilder(storyReporterBuilder())
.useStoryPathResolver(storyPathResolver())
.useParameterControls(parameterControls())
.useParameterConverters(parameterConverters);
}
Lastly, I think a Spring context was not being autowired properly, so I changed the stepsFactory() method like this (again copied from the maven template):
#Override
public InjectableStepsFactory stepsFactory() {
ApplicationContext appContext = new SpringApplicationContextFactory("jbehave-app-context.xml")
.createApplicationContext();
return new SpringStepsFactory(configuration(), appContext);
}
Related
After updating to GAE 1.9.49 Maven fails to execute goal endpoints_get_discovery_doc
I tried to update the GAE version to the latest 1.9.49 released on Jan 30, 2017, and encountered the following issue: [INFO] --- appengine-maven-plugin:1.9.49:endpoints_get_discovery_doc (default) # dugout-api-web --- [INFO] [INFO] Google App Engine Java SDK - get endpoints discovery doc... [INFO] Using Class Name: com.project.api.resource.admin.AFDApiService [INFO] Using Class Name: com.project.api.resource.admin.AFLApiService [INFO] Using Class Name: com.project.api.resource.admin.AFSApiService [INFO] Using Class Name: com.project.api.resource.admin.ALApiService [INFO] Using Class Name: com.project.api.resource.admin.APApiService [INFO] Using Class Name: com.project.api.resource.admin.ARApiService [INFO] Using Class Name: com.project.api.resource.admin.AUApiService [INFO] Using Class Name: com.project.api.resource.admin.AUtApiService [INFO] Using Class Name: com.project.api.resource.admin.BaseAdminApiService [INFO] Using Class Name: com.project.api.resource.BaseApiService [INFO] Using Class Name: com.project.api.resource.chat.ChatApiService [INFO] Using Class Name: com.project.api.resource.pub.BasePublicApiService [INFO] Using Class Name: com.project.api.resource.pub.f.FDApiService [INFO] Using Class Name: com.project.api.resource.pub.f.FDrApiService [INFO] Using Class Name: com.project.api.resource.pub.f.FLApiService [INFO] Using Class Name: com.project.api.resource.pub.f.FSApiService [INFO] Using Class Name: com.project.api.resource.pub.f.FTApiService [INFO] Using Class Name: com.project.api.resource.pub.GCrApiService [INFO] Using Class Name: com.project.api.resource.pub.PApiService [INFO] Using Class Name: com.project.api.resource.pub.SApiService [INFO] Using Class Name: com.project.api.resource.pub.UApiService [INFO] Executing endpoints Command=[get-discovery-doc, -cp, D:\project\project-api\project-api-web\target\project-api-web-develop-SNAPSHOT\WEB-INF\classes;D:\project\project-api\project-api-web\target/classes;D:\project\project-api\project-common\target\project-common-develop-SNAPSHOT.jar;D:\mvn_repo\com\googlecode\objectify\objectify\5.1.8\objectify-5.1.8.jar;D:\mvn_repo\com\google\code\gson\gson\2.3.1\gson-2.3.1.jar;D:\mvn_repo\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;D:\mvn_repo\com\fasterxml\jackson\dataformat\jackson-dataformat-xml\2.5.4\jackson-dataformat-xml-2.5.4.jar;D:\mvn_repo\com\fasterxml\jackson\core\jackson-core\2.5.4\jackson-core-2.5.4.jar;D:\mvn_repo\com\fasterxml\jackson\core\jackson-annotations\2.5.0\jackson-annotations-2.5.0.jar;D:\mvn_repo\com\fasterxml\jackson\module\jackson-module-jaxb-annotations\2.5.4\jackson-module-jaxb-annotations-2.5.4.jar;D:\mvn_repo\org\codehaus\woodstox\stax2-api\3.1.4\stax2-api-3.1.4.jar;D:\project\project-api\project-service-email\target\project-service-email-develop-SNAPSHOT.jar;D:\mvn_repo\com\mandrillapp\wrapper\lutung\lutung\0.0.5\lutung-0.0.5.jar;D:\mvn_repo\commons-io\commons-io\1.3.2\commons-io-1.3.2.jar;D:\mvn_repo\com\sendgrid\sendgrid-java\2.2.2\sendgrid-java-2.2.2.jar;D:\mvn_repo\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar;D:\mvn_repo\org\apache\httpcomponents\httpmime\4.3.4\httpmime-4.3.4.jar;D:\mvn_repo\org\json\json\20140107\json-20140107.jar;D:\mvn_repo\com\sendgrid\smtpapi-java\1.2.0\smtpapi-java-1.2.0.jar;D:\mvn_repo\org\apache\httpcomponents\httpclient\4.3.4\httpclient-4.3.4.jar;D:\mvn_repo\com\github\spullara\mustache\java\compiler\0.8.17\compiler-0.8.17.jar;D:\mvn_repo\commons-logging\commons-logging\1.1\commons-logging-1.1.jar;D:\mvn_repo\log4j\log4j\1.2.12\log4j-1.2.12.jar;D:\mvn_repo\logkit\logkit\1.0.1\logkit-1.0.1.jar;D:\mvn_repo\avalon-framework\avalon-framework\4.1.3\avalon-framework-4.1.3.jar;D:\project\project-api\project-persistence\target\project-persistence-develop-SNAPSHOT.jar;D:\project\project-api\project-cache\target\project-cache-develop-SNAPSHOT.jar;D:\mvn_repo\org\apache\commons\commons-collections4\4.0\commons-collections4-4.0.jar;D:\project\project-api\project-service\target\project-service-develop-SNAPSHOT.jar;D:\mvn_repo\com\gocardless\gocardless-java\3.1.0\gocardless-java-3.1.0.jar;D:\mvn_repo\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\mvn_repo\com\fasterxml\jackson\core\jackson-databind\2.5.4\jackson-databind-2.5.4.jar;D:\project\project-api\project-service-channel\target\project-service-channel-develop-SNAPSHOT.jar;D:\mvn_repo\com\pusher\pusher-rest-java\0.9.0\pusher-rest-java-0.9.0.jar;D:\project\project-api\project-api-opta\target\project-api-opta-develop-SNAPSHOT.jar;D:\mvn_repo\com\thoughtworks\xstream\xstream\1.4.8\xstream-1.4.8.jar;D:\mvn_repo\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;D:\mvn_repo\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar;D:\mvn_repo\com\google\appengine\tools\appengine-gcs-client\0.6\appengine-gcs-client-0.6.jar;D:\mvn_repo\com\google\apis\google-api-services-storage\v1-rev68-1.21.0\google-api-services-storage-v1-rev68-1.21.0.jar;D:\mvn_repo\com\google\api-client\google-api-client\1.21.0\google-api-client-1.21.0.jar;D:\mvn_repo\com\google\oauth-client\google-oauth-client\1.21.0\google-oauth-client-1.21.0.jar;D:\mvn_repo\com\google\api-client\google-api-client-appengine\1.22.0\google-api-client-appengine-1.22.0.jar;D:\mvn_repo\com\google\oauth-client\google-oauth-client-appengine\1.22.0\google-oauth-client-appengine-1.22.0.jar;D:\mvn_repo\com\google\oauth-client\google-oauth-client-servlet\1.22.0\google-oauth-client-servlet-1.22.0.jar;D:\mvn_repo\com\google\http-client\google-http-client-jdo\1.22.0\google-http-client-jdo-1.22.0.jar;D:\mvn_repo\com\google\api-client\google-api-client-servlet\1.22.0\google-api-client-servlet-1.22.0.jar;D:\mvn_repo\javax\jdo\jdo2-api\2.3-eb\jdo2-api-2.3-eb.jar;D:\mvn_repo\javax\transaction\transaction-api\1.1\transaction-api-1.1.jar;D:\mvn_repo\com\google\http-client\google-http-client-appengine\1.22.0\google-http-client-appengine-1.22.0.jar;D:\mvn_repo\com\google\http-client\google-http-client\1.22.0\google-http-client-1.22.0.jar;D:\mvn_repo\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;D:\mvn_repo\com\google\http-client\google-http-client-jackson2\1.22.0\google-http-client-jackson2-1.22.0.jar;D:\mvn_repo\org\codehaus\woodstox\woodstox-core-asl\4.1.4\woodstox-core-asl-4.1.4.jar;D:\mvn_repo\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar;D:\project\project-api\project-api-euros\target\project-api-euros-develop-SNAPSHOT.jar;D:\mvn_repo\com\google\inject\extensions\guice-persist\4.0\guice-persist-4.0.jar;D:\mvn_repo\commons-beanutils\commons-beanutils\1.9.2\commons-beanutils-1.9.2.jar;D:\mvn_repo\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;D:\mvn_repo\com\google\appengine\appengine-remote-api\1.9.28\appengine-remote-api-1.9.28.jar;D:\mvn_repo\com\google\appengine\appengine-api-1.0-sdk\1.9.49\appengine-api-1.0-sdk-1.9.49.jar;D:\mvn_repo\com\google\appengine\appengine-endpoints\1.9.49\appengine-endpoints-1.9.49.jar;D:\mvn_repo\com\google\inject\guice\4.0\guice-4.0.jar;D:\mvn_repo\javax\inject\javax.inject\1\javax.inject-1.jar;D:\mvn_repo\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\mvn_repo\com\google\inject\extensions\guice-servlet\4.0\guice-servlet-4.0.jar;D:\mvn_repo\com\google\guava\guava\18.0\guava-18.0.jar;D:\mvn_repo\joda-time\joda-time\2.7\joda-time-2.7.jar;D:\mvn_repo\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar;D:\mvn_repo\com\google\appengine\appengine-api-labs\1.9.49\appengine-api-labs-1.9.49.jar;D:\mvn_repo\org\scribe\scribe\1.3.6\scribe-1.3.6.jar, -o, D:\project\project-api\project-api-web\target/generated-sources/appengine-endpoints/WEB-INF, -w, D:\project\project-api\project-api-web\target/generated-sources/appengine-endpoints, -f, rest, com.project.api.resource.admin.AFDApiService, com.project.api.resource.admin.AFLApiService, com.project.api.resource.admin.AFSApiService, com.project.api.resource.admin.ALApiService, com.project.api.resource.admin.APApiService, com.project.api.resource.admin.ARApiService, com.project.api.resource.admin.AUApiService, com.project.api.resource.admin.AUtApiService, com.project.api.resource.admin.BaseAdminApiService, com.project.api.resource.BaseApiService, com.project.api.resource.chat.ChatApiService, com.project.api.resource.pub.BasePublicApiService, com.project.api.resource.pub.f.FDApiService, com.project.api.resource.pub.f.FDrApiService, com.project.api.resource.pub.f.FLApiService, com.project.api.resource.pub.f.FSApiService, com.project.api.resource.pub.f.FTApiService, com.project.api.resource.pub.GCrApiService, com.project.api.resource.pub.PApiService, com.project.api.resource.pub.SApiService, com.project.api.resource.pub.UApiService] [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] project-api ......................................... SUCCESS [ 4.547 s] [INFO] project-common-test-dep ............................. SUCCESS [ 0.430 s] [INFO] project-common ...................................... SUCCESS [ 7.699 s] [INFO] project-cache ....................................... SUCCESS [ 1.026 s] [INFO] project-persistence ................................. SUCCESS [ 3.256 s] [INFO] project-common-test-utils ........................... SUCCESS [ 0.727 s] [INFO] project-service-email ............................... SUCCESS [ 1.296 s] [INFO] project-service-channel ............................. SUCCESS [ 1.263 s] [INFO] project-service ..................................... SUCCESS [ 5.777 s] [INFO] project-api-opta .................................... SUCCESS [ 4.171 s] [INFO] project-api-euros ................................... SUCCESS [ 1.577 s] [INFO] project-api-web ..................................... FAILURE [ 3.696 s] [INFO] project-api-import .................................. SKIPPED [INFO] project-api-task .................................... SKIPPED [INFO] project-build-ear ................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 35.682 s [INFO] Finished at: 2017-02-01T20:09:52+02:00 [INFO] Final Memory: 55M/485M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.google.appengine:appengine-maven-plugin:1.9.49:endpoints_get_discovery_doc (default) on project project-api-web: -f -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.google.appengine:appengine-maven-plugin:1.9.49:endpoints_get_discovery_doc (default) on project project-api-web: -f at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) 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:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) 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: org.apache.maven.plugin.MojoExecutionException: -f at com.google.appengine.endpoints.EndpointsMojo.executeEndpointsCommand(EndpointsMojo.java:114) at com.google.appengine.endpoints.EndpointsGetDiscoveryDoc.execute(EndpointsGetDiscoveryDoc.java:47) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) ... 20 more For previous versions the build succeeded for the same goal. Part of the relevant project-api-web\pom.xml is shown below: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml> <webResources> <resource> <!-- this is relative to the pom.xml directory --> <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory> <!-- the list has a default value of ** --> <includes> <include>WEB-INF/*.discovery</include> <include>WEB-INF/*.api</include> </includes> </resource> </webResources> </configuration> </plugin> <plugin> <groupId>com.google.appengine</groupId> <artifactId>appengine-maven-plugin</artifactId> <version>${appengine.target.version}</version> <configuration> <enableJarClasses>false</enableJarClasses> </configuration> <executions> <execution> <goals> <goal>endpoints_get_discovery_doc</goal> </goals> </execution> </executions> </plugin> </plugins> </build> It appears that after update com.google.api.server.spi.tools.EndpointsTool fails to handle the format option: -f, rest So currently the update is reverted to version 1.9.48 as a workaround. Any help/suggestions will be highly appreciated.
Working on it. Fix will be in 1.9.50 release.
I've reported this issue to the GitHub tracker for the appengine-maven-plugin. It appears specific to this component as changing the version for the plugin specifically is what affects the bug. There is also another issue which was reported recently on that tracker regarding deployments which seems dependent on this one.
Maven runs test but it does not display results
I've just started working with maven and I can't figure out how to solve the problem I have. It seems to my java file is compiled and test starts but no result shows up. Demo.java: package tutorial2; public class Demo { public boolean getBool(){ return false; } } TestDemo.java: package tutorial2; import static org.junit.Assert.*; import org.junit.Test; public class TestDemo { #Test public void shouldBe(){ Demo demo = new Demo(); assertTrue(demo.getBool()); } } 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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>lets.develop.withme</groupId> <artifactId>tutorial2</artifactId> <version>0.0.1-SNAPSHOT</version> <name>Tutorial 02</name> <description>My second tutorial</description> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.2</version> <scope>test</scope> </dependency> </dependencies> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </pluginManagement> </build> </project I'm getting this on console: [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Tutorial 02 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) # tutorial2 --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # tutorial2 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # tutorial2 --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # tutorial2 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # tutorial2 --- [INFO] Surefire report directory: /home/adam/workspaceJavaEE/tutorial2/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running tutorial2.TestDemo Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.943 s [INFO] Finished at: 2016-10-14T00:34:25+02:00 [INFO] Final Memory: 10M/212M [INFO] ------------------------------------------------------------------------ Solved: I solved problem by myself. Dependency in xml file was not configured properly. Version of junit dependency was wrong so It could't be run by maven. Advise: You should always add dependencies by "Insert Dependency" menu. It can be displayed by using shortcut "crtl"+"space" when your cursor is between <dependency> and </dependency> in your xml file. When you in "Select Dependency" menu enter "junit" in "Enter..." textbox and choose your version of junit. After clicking "ok" your dependency will be automatically added. This helps avoid problem with incorrect version typed manually.
By default, Surefire (the plugin that runs during mvn test) looks for classes in target/test-classes (which are compiled from src/test/java and maybe other places) that end in Test. Your class name is TestDemo, which doesn't end in Test, and won't be run. Either rename it to DemoTest (preferable), or manually configure Surefire in <plugins> (the approach when you're using a framework with alternate naming conventions, such as Spock's *Spec).
According to maven documentation avalible on: By default, the Surefire Plugin will automatically include all test classes with the following wildcard patterns: "/Test*.java" - includes all of its subdirectories and all Java filenames that start with "Test". "/*Test.java" - includes all of its subdirectories and all Java filenames that end with "Test". "/*TestCase.java" - includes all of its subdirectories and all Java filenames that end with "TestCase".
Getting maven exception but whereas works fine running from cucumber runner file
I have a maven cucumber project, when i run the Runner.java file(run as junit test), the testcases are working fine. I have configured the same project in Jenkins like below. It was working fine earlier, but now getting below error message. When i build this project i am getting below error: Can someone help me to overcome this problem. Started by user anonymous Building in workspace C:\Users\user\.jenkins\workspace\LeninCukesMaven FSSCM.checkout E:\Programming\Cucumber\LinenHousePOC to C:\Users\user\.jenkins\workspace\LeninCukesMaven Modified file: target\cucumber\cucumber.json Modified file: target\cucumber\formatter.js Modified file: target\cucumber\index.html Modified file: target\cucumber\jquery-1.8.2.min.js Modified file: target\cucumber\report.js Modified file: target\cucumber\style.css Modified file: target\extent\ExtentResultReport.html Modified file: target\surefire-reports\bullet_point.png Modified file: target\surefire-reports\collapseall.gif Modified file: target\surefire-reports\emailable-report.html Modified file: target\surefire-reports\failed.png Modified file: target\surefire-reports\index.html Modified file: target\surefire-reports\jquery-1.7.1.min.js Modified file: target\surefire-reports\navigator-bullet.png Modified file: target\surefire-reports\old\index.html Modified file: target\surefire-reports\old\runners.RunnerTest\classes.html Modified file: target\surefire-reports\old\runners.RunnerTest\Command line test.properties Modified file: target\surefire-reports\old\runners.RunnerTest\groups.html Modified file: target\surefire-reports\old\runners.RunnerTest\index.html Modified file: target\surefire-reports\old\runners.RunnerTest\main.html Modified file: target\surefire-reports\old\runners.RunnerTest\methods-alphabetical.html Modified file: target\surefire-reports\old\runners.RunnerTest\methods-not-run.html Modified file: target\surefire-reports\old\runners.RunnerTest\methods.html Modified file: target\surefire-reports\old\runners.RunnerTest\reporter-output.html Modified file: target\surefire-reports\old\runners.RunnerTest\testng.xml.html Modified file: target\surefire-reports\old\runners.RunnerTest\toc.html Modified file: target\surefire-reports\passed.png Modified file: target\surefire-reports\runners.RunnerTest\Command line test.html Modified file: target\surefire-reports\runners.RunnerTest\Command line test.xml Modified file: target\surefire-reports\runners.RunnerTest\testng-failed.xml Modified file: target\surefire-reports\runners.RunnerTest.txt Modified file: target\surefire-reports\skipped.png Modified file: target\surefire-reports\TEST-runners.RunnerTest.xml Modified file: target\surefire-reports\testng-failed.xml Modified file: target\surefire-reports\testng-reports.css Modified file: target\surefire-reports\testng-reports.js Modified file: target\surefire-reports\testng-results.xml Modified file: target\surefire-reports\testng.css Modified file: target\test-classes\helpers\Hooks.class Modified file: target\test-classes\helpers\utils$StepStatus.class Modified file: target\test-classes\helpers\utils.class Modified file: target\test-classes\pageobjects\DeliveryAndPaymentPage.class Modified file: target\test-classes\pageobjects\HomePage.class Modified file: target\test-classes\pageobjects\LoginPage.class Modified file: target\test-classes\pageobjects\MyAccountPage.class Modified file: target\test-classes\pageobjects\ProductDetailsPage.class Modified file: target\test-classes\pageobjects\ProductsListPage.class Modified file: target\test-classes\pageobjects\RegistrationFormPage.class Modified file: target\test-classes\runners\RunnerTest.class Modified file: target\test-classes\stepdefinitions\DeliveryAndPaymentSteps.class Modified file: target\test-classes\stepdefinitions\HomeSteps.class Modified file: target\test-classes\stepdefinitions\LoginSteps.class Modified file: target\test-classes\stepdefinitions\MyAccountSteps.class Modified file: target\test-classes\stepdefinitions\ProductDetailsSteps.class Modified file: target\test-classes\stepdefinitions\ProductsListSteps.class Modified file: target\test-classes\stepdefinitions\RegistrationFormSteps.class Deleted file: target\cucumber\embedded0.png Deleted file: target\cucumber\embedded1.png Deleted file: target\cucumber.json Deleted file: testng.xml FSSCM.check completed in 723 milliseconds Parsing POMs [LeninCukesMaven] $ "C:\Program Files\Java\jdk1.8.0_25/bin/java" -cp C:\Users\user\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-agent-1.5.jar;C:\Users\user\.jenkins\tools\hudson.tasks.Maven_MavenInstallation\D_softies_apache-maven-3.3.3\boot\plexus-classworlds-2.5.2.jar;C:\Users\user\.jenkins\tools\hudson.tasks.Maven_MavenInstallation\D_softies_apache-maven-3.3.3/conf/logging jenkins.maven3.agent.Maven31Main C:\Users\user\.jenkins\tools\hudson.tasks.Maven_MavenInstallation\D_softies_apache-maven-3.3.3 C:\Users\user\.jenkins\war\WEB-INF\lib\remoting-2.59.jar C:\Users\user\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-interceptor-1.5.jar C:\Users\user\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.5.jar 50080 <===[JENKINS REMOTING CAPACITY]===>channel started Executing Maven: -B -f C:\Users\user\.jenkins\workspace\LeninCukesMaven\pom.xml test -Dtest=runners.RunnerTest.java [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building CucumberPractice 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) # CucumberPractice --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory C:\Users\user\.jenkins\workspace\LeninCukesMaven\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # CucumberPractice --- [INFO] No sources to compile [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # CucumberPractice --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory C:\Users\user\.jenkins\workspace\LeninCukesMaven\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # CucumberPractice --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # CucumberPractice --- [INFO] Surefire report directory: C:\Users\user\.jenkins\workspace\LeninCukesMaven\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running runners.RunnerTest Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator#7f7052 Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.269 sec Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [JENKINS] Recording test results [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 12.994 s [INFO] Finished at: 2016-07-01T20:23:39+05:30 [INFO] Final Memory: 10M/25M [INFO] ------------------------------------------------------------------------ Waiting for Jenkins to finish collecting data [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project CucumberPractice: No tests were executed! (Set -DfailIfNoTests=false to ignore this 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] [JENKINS] Archiving C:\Users\user\.jenkins\workspace\LeninCukesMaven\pom.xml to com.cucumber/CucumberPractice/0.0.1-SNAPSHOT/CucumberPractice-0.0.1-SNAPSHOT.pom [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 channel stopped [CucumberReportPublisher] Compiling Cucumber Html Reports ... [CucumberReportPublisher] Copying all json files from: C:\Users\user\.jenkins\workspace\LeninCukesMaven to reports directory: C:\Users\user\.jenkins\jobs\LeninCukesMaven\builds\26\cucumber-html-reports [CucumberReportPublisher] Found 1 json files. [CucumberReportPublisher] 1. Found a json file: target\cucumber\cucumber.json [CucumberReportPublisher] Generating HTML reports Finished: FAILURE My pom.xml looks like this:(Is it causing any issues, did i miss anything in my pom.xml) http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 <groupId>com.cucumber</groupId> <artifactId>LinenHousePOC</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>LinenHousePOC</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.2.4</version> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-picocontainer</artifactId> <version>1.2.4</version> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>1.2.4</version> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-testng</artifactId> <version>1.1.5</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.47.1</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.9.10</version> </dependency> <dependency> <groupId>com.relevantcodes</groupId> <artifactId>extentreports</artifactId> <version>2.41.0</version> </dependency> </dependencies>
Why maven-surefire-plugin skip tests with log message "because it has already been run for this configuration"?
I can't understand why maven-surefire-plugin doesn't run jUnit4 test. My pom is (can't add it here because "it looks post is mostly code"): http://pastebin.com/Jj3iJZpY When I execute mvn clean test cmd window shows: C:\Users\maya\git\services>mvn clean test [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building services 1.0.18 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) # services --- [INFO] Deleting C:\Users\maya\git\services\target [INFO] [INFO] --- maven-mule-plugin:1.9:attach-test-resources (default-attach-test-resources) # services --- [INFO] attaching test resource C:\Users\maya\git\services\src\main\app [INFO] [INFO] --- build-helper-maven-plugin:1.7:add-resource (add-resource) # services --- [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) # services --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 4 resources [INFO] Copying 3 resources [INFO] Copying 0 resource [INFO] [INFO] --- maven-mule-plugin:1.9:filter-resources (default-filter-resources) # services --- [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # services --- [INFO] Compiling 60 source files to C:\Users\maya\git\services\target\classes [INFO] [INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) # services --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # services --- [INFO] Compiling 1 source file to C:\Users\maya\git\services\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.19:test (default-test) # services --- [INFO] [INFO] --- maven-surefire-plugin:2.19:test (default) # services --- [INFO] Skipping execution of surefire because it has already been run for this configuration [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8.554 s [INFO] Finished at: 2015-12-11T15:48:05+03:00 [INFO] Final Memory: 48M/312M [INFO] ------------------------------------------------------------------------ Test class is: package com.comp.utils.UtilsTest; import static org.junit.Assert.assertTrue; import org.apache.log4j.Logger; import org.junit.Test; public class UtilsTest { private static final Logger LOG = Logger.getLogger(UtilsTest.class.getName()); #Test public void testHasPersonSameProd() { boolean hasSameProduct = false; assertTrue("Should be True", hasSameProduct); } } Why maven-surefire-plugin:2.19 runs twice and doesn't want to run my test class? How to run test in my case? Thank you.
Given the pom you linked (which should be included into the question actually, as the link may be broken in the future): <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19</version> <executions> <execution> <goals> <goal>test</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit47</artifactId> <version>2.19</version> </dependency> </dependencies> <configuration> <includes> <include>UtilTest.java</include> </includes> </configuration> </plugin> The Maven Surefire Plugin runs twice because you configured an additional execution of the plugin, without providing an id element and as such by default it is called default (maven-surefire-plugin:2.19:test (default)). This execution runs after the out-of-the-box Maven configuration for Surefire (maven-surefire-plugin:2.19:test (default-test)). So, as a consequence, you have two executions (default and default-test). Removing the executions section on the Surefire plugin configuration you would only have one execution (the default-test). You also have a typo in the Surefire configuration, the <include>UtilTest.java</include> configuration points to the UtilTest.java class, while in your question it is named UtilsTest (note the additional 's'). If the test class is under src/test/java folder, then you don't need to configure its inclusion, since it also already follow the default convention of Surefire, "**/*Test.java". The message you are having (Skipping execution of surefire because it has already been run for this configuration) is because your configuration element for the Surefire plugin is outside any executions element, which means is applied to all plugin executions, even the default one (default-test). So you could probably remove the whole Surefire plugin section from your pom and the issue should be fixed.
Maven Tomcat7:deploy "Cannot invoke Tomcat manager: Connection refused: connect"
I'm trying to deploy my web app on Tomcat 7 with Maven (version 3.2.1), but getting exception listed in the title. I've tried following solutions from questions (tomcat:deploy: "Cannot invoke Tomcat manager: Connection refused", Tomcat deployement issue in a Maven project): Use tomcat user with manager-script role (respectfully edited settings.xml, pom.xml, tomcat-users.xml) Deploy without specifying tomcat user. Use diff maven commands e.g.: clean install tomcat7:deploy, clean tomcat7:deploy, tomcat7:redeploy, tomcat7:redeploy-only. Also I should mention that if I'm running app on server without maven i.e. Project > Run As > Run on Server or using maven tomcat7-run goals i.e. clean install tomcat7:run then it all works as fine. This is how I edit settings.xml, pom.xml, tomcat-users.xml when using tomcat user. tomcat-users.xml: <tomcat-users> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <role rolename="admin-gui"/> <role rolename="admin-script"/> <user username="user" password="pass" roles="manager-script"></user> </tomcat-users> settings.xml: <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>${user.home}/.m2/repository</localRepository> <interactiveMode>true</interactiveMode> <usePluginRegistry>false</usePluginRegistry> <offline>false</offline> <servers> <server> <id>apache-tomcat-7</id> <username>user</username> <password>pass</password> </server> </servers> </settings> 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>org.example.company</groupId> <artifactId>magazine</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>market Maven Webapp</name> <url>http://maven.apache.org</url> <build> <finalName>${project.artifactId}</finalName> <outputDirectory>${CATALINA_HOME}/webapps/${project.artifactId}/${project.artifactId}</outputDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <server>apache-tomcat-7</server> <url>http://localhost:8080/manager/text</url> <path>/${project.artifactId}</path> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> </plugin> </plugins> </build> ...//dependencies </project> EDIT: My Maven output with goals clean install tomcat7:deploy -e [INFO] Error stacktraces are turned on. [INFO] Scanning for projects... [INFO] [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building market Maven Webapp 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) # magazine --- [INFO] Deleting D:\git\magazine\target [INFO] Deleting D:\EclipseWorkspace\apache-tomcat-7.0.59\webapps\magazine\magazine [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) # magazine --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 4 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # magazine --- [INFO] Changes detected - recompiling the module! [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 19 source files to D:\EclipseWorkspace\apache-tomcat-7.0.59\webapps\magazine\magazine [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # magazine --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\git\magazine\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # magazine --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # magazine --- [INFO] No tests to run. [INFO] [INFO] --- maven-war-plugin:2.4:war (default-war) # magazine --- [INFO] Packaging webapp [INFO] Assembling webapp [magazine] in [D:\git\magazine\target\magazine] [INFO] Processing war project [INFO] Copying webapp resources [D:\git\magazine\src\main\webapp] [INFO] Webapp assembled in [376 msecs] [INFO] Building war: D:\git\magazine\target\magazine.war [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) # magazine --- [INFO] Installing D:\git\magazine\target\magazine.war to C:\Users\Mark\.m2\repository\ua\khpi\norkin\magazine\0.0.1-SNAPSHOT\magazine-0.0.1-SNAPSHOT.war [INFO] Installing D:\git\magazine\pom.xml to C:\Users\Mark\.m2\repository\ua\khpi\norkin\magazine\0.0.1-SNAPSHOT\magazine-0.0.1-SNAPSHOT.pom [INFO] [INFO] >>> tomcat7-maven-plugin:2.2:deploy (default-cli) # magazine >>> [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) # magazine --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 4 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # magazine --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # magazine --- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory D:\git\magazine\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # magazine --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # magazine --- [INFO] No tests to run. [INFO] Skipping execution of surefire because it has already been run for this configuration [INFO] [INFO] --- maven-war-plugin:2.4:war (default-war) # magazine --- [INFO] Packaging webapp [INFO] Assembling webapp [magazine] in [D:\git\magazine\target\magazine] [INFO] Processing war project [INFO] Copying webapp resources [D:\git\magazine\src\main\webapp] [INFO] Webapp assembled in [221 msecs] [INFO] Building war: D:\git\magazine\target\magazine.war [INFO] [INFO] <<< tomcat7-maven-plugin:2.2:deploy (default-cli) # magazine <<< [INFO] [INFO] --- tomcat7-maven-plugin:2.2:deploy (default-cli) # magazine --- [INFO] Deploying war to http://localhost:8080/magazine [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 10.622 s [INFO] Finished at: 2015-03-08T11:09:46+02:00 [INFO] Final Memory: 25M/221M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project magazine: Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project magazine: Cannot invoke Tomcat manager at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) 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:108) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213) at org.apache.maven.cli.MavenCli.main(MavenCli.java:157) 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:483) 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: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager at org.apache.tomcat.maven.plugin.tomcat7.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141) at org.apache.tomcat.maven.plugin.tomcat7.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:68) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 19 more Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117) at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178) at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304) at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) at org.apache.tomcat.maven.common.deployer.TomcatManager.invoke(TomcatManager.java:742) at org.apache.tomcat.maven.common.deployer.TomcatManager.deployImpl(TomcatManager.java:705) at org.apache.tomcat.maven.common.deployer.TomcatManager.deploy(TomcatManager.java:388) at org.apache.tomcat.maven.plugin.tomcat7.deploy.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85) at org.apache.tomcat.maven.plugin.tomcat7.deploy.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:82) at org.apache.tomcat.maven.plugin.tomcat7.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:132) ... 22 more [ERROR] [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 Also there is no log file in ${CATALINA_HOME}/logs - what I have is empty folder. Besides there is no ${project.dir}/target/tomcat folder that I observed before. Also should this option be checked ?