tomcat7:run fails where as tomcat7:run-war-only works - maven

I have a simple (REST) web app which throws below error when I run mvn tomcat7:run,
where as it works fine with mvn tomcat7:run-war-only.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Could not start Tomcat
Embedded error: Failed to start component [StandardServer[-1]]
A child container failed during start
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Could not start Tomcat
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Could not start Tomcat
at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.execute(AbstractRunMojo.java:486)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:335)
at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.startContainer(AbstractRunMojo.java:1018)
at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.execute(AbstractRunMojo.java:478)
... 19 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 22 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 24 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 26 more
Below is tomcat configuration from pom.xml,
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<contextFile>${basedir}/src/test/resources/context.xml</contextFile>
<useTestClasspath>true</useTestClasspath>
<systemProperties>
<systemProperty>
<name>maven.tomcat.port</name>
<value>8090</value>
</systemProperty>
</systemProperties>
</configuration>
<version>2.0</version>
<executions>
<execution>
<id>tomcat7-run</id>
<goals>
<goal>run-war-only</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<fork>true</fork>
<port>8090</port>
</configuration>
</execution>
<execution>
<id>tomcat-shutdown</id>
<goals>
<goal>shutdown</goal>
</goals>
<phase>post-integration-test</phase>
<configuration>
<fork>true</fork>
<port>8090</port>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-spring</artifactId>
<version>3.4.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
Any help on how to resolve this this issue or how to debug this further will be appreciated.
Thanks and Regards,
Shrey

In my case it happened because of servlet-api dependency coming from jetty. It's unclear from stacktrace but it can be found when debugging tomcat plugin.
Check out maven dependencies for your module with mvn dependency:tree and look for servlet-api transitive dependencies. Once found exclude it from build.

Related

Running a 'Main' class before starting integration tests

I have a few integration tests that I want to run against a custom server that is started in the main method.
I have the below in the pom.xml:
<project>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<execution>
<id>start the server for integration tests</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<async>false</async>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>com.abc.def.integration.Main</argument>
</arguments>
</configuration>
</execution>
<execution>
<phase>post-integration-test</phase>
<goals/>
</execution>
</plugin>
</plugins>
</build>
</project>
The tests will be later executed using the failsafe plugin.
But currently I am getting a ClassNotFoundException for the Main class:
INFO] --- exec-maven-plugin:1.6.0:exec (start the server for integration tests) # rest ---
Error: Could not find or load main class com.abc.def.integration.Main
Caused by: java.lang.ClassNotFoundException: com.abc.def.integration.Main
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:804)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:751)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:313)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
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:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.161 s
[INFO] Finished at: 2019-08-29T14:10:46+05:30
[INFO] Final Memory: 47M/506M
[INFO] ------------------------------------------------------------------------
It looks like a classpath issue, But the Main class is part of the project being complied by the maven.
Is there a way to execute the Main method without manually specifying the classpath during the build? (like without : -Dexec.args="%classpath")
Should I be using another maven plugin to execute this class?
I solved the issue by the method described in: http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/
With below change to the execution section:
<execution>
<id>start the server for integration tests</id>
<phase>pre-integration-test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>com.abc.def.integration.Main</mainClass>
</configuration>
</execution>

NoClassDefFoundError when using cxf-codegen-plugin with maven

I'm trying to convert wsdl into java using maven and cxf-codegen-plugin but i always get the same error:
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java (aspsms) on project webapp: org/apache/velocity/context/Context: org.apache.velocity.context.Context -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java (aspsms) on project webapp: org/apache/velocity/context/Context
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.MojoExecutionException: org/apache/velocity/context/Context
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:435)
at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:260)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:512)
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: java.lang.NoClassDefFoundError: org/apache/velocity/context/Context
at org.apache.cxf.tools.wsdlto.core.AbstractGenerator.<init>(AbstractGenerator.java:47)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.AbstractJAXWSGenerator.<init>(AbstractJAXWSGenerator.java:30)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.AntGenerator.<init>(AntGenerator.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at org.apache.cxf.tools.wsdlto.core.PluginLoader.getFrontEndGenerators(PluginLoader.java:278)
at org.apache.cxf.tools.wsdlto.core.PluginLoader.getFrontEndProfile(PluginLoader.java:393)
at org.apache.cxf.tools.wsdlto.WSDLToJava.loadFrontEnd(WSDLToJava.java:64)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:96)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:415)
... 24 more
Caused by: java.lang.ClassNotFoundException: org.apache.velocity.context.Context
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
... 38 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
My mvn version:
$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /Users/user/Desktop/dev/ses/apps/apache-maven-3.3.9
Java version: 1.8.0_101, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
Here is my pom file:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<id>aspsms</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/generated-source</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/wsdl/aspsmsx2.wsdl</wsdl>
<extraargs>
<extraarg>-p</extraarg>
<extraarg>com.test.service.adapter.aspsms.wsclient</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
The jar files were correctly downloaded in my maven repo. Do you have an advice?
Maybe you can add explicitly the dependency to velocity in the plugin configuration
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<id>aspsms</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/generated-source</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/wsdl/aspsmsx2.wsdl</wsdl>
<extraargs>
<extraarg>-p</extraarg>
<extraarg>com.test.service.adapter.aspsms.wsclient</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
</dependencies>
</plugin>

Why does jbehave-maven-plugin give me a NoClassDefFoundError?

I get the following error when I run mvn integration-test -e com.example.mymodule:
[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:3.9.5:run-stories-as-embeddables (embeddable-stories) on project com.example.mymodule: Failed to run stories as embeddables: Failure in running embeddable: com.example.mymodule.TheStories: Could not initialize class freemarker.ext.beans.BeansWrapper -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jbehave:jbehave-maven-plugin:3.9.5:run-stories-as-embeddables (embeddable-stories) on project com.example.mymodule: 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: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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: org.jbehave.core.embedder.Embedder$RunningEmbeddablesFailed: Failure in running embeddable: com.example.mymodule.TheStories
at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:130)
at org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:18)
... 21 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class freemarker.ext.beans.BeansWrapper
at freemarker.template.ObjectWrapper.<clinit>(ObjectWrapper.java:69)
at freemarker.core.Configurable.<init>(Configurable.java:139)
at freemarker.template.Configuration.<init>(Configuration.java:142)
at freemarker.template.Configuration.<clinit>(Configuration.java:127)
at org.jbehave.core.reporters.FreemarkerProcessor.configuration(FreemarkerProcessor.java:30)
at org.jbehave.core.reporters.FreemarkerProcessor.process(FreemarkerProcessor.java:21)
at org.jbehave.core.reporters.TemplateableViewGenerator.write(TemplateableViewGenerator.java:267)
at org.jbehave.core.reporters.TemplateableViewGenerator.createReports(TemplateableViewGenerator.java:219)
at org.jbehave.core.reporters.TemplateableViewGenerator.generateReportsView(TemplateableViewGenerator.java:110)
at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:249)
at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:237)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:213)
at org.jbehave.core.junit.JUnitStories.run(JUnitStories.java:20)
at org.jbehave.core.embedder.Embedder.runAsEmbeddables(Embedder.java:121)
... 22 more
When I run mvn dependency:tree -pl com.example.mymodule | grep freemarker I get
[INFO] | +- org.freemarker:freemarker:jar:2.3.19:compile
I used javap to confirm that the class freemarker.ext.beans.BeansWrapper exists in this jar:
javap -classpath C:\Users\CONOR2\.m2\repository\org\freemarker\freemarker\2.3.19\freemarker-2.3.19.jar freemarker.ext.beans.BeansWrapper
Here's the relevant portion of my depdendencies from my pom.xml:
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>3.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>3.9.5</version>
<classifier>resources</classifier>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.jbehave.site</groupId>
<artifactId>jbehave-site-resources</artifactId>
<version>3.2</version>
<type>zip</type>
</dependency>
Here's my plugin section:
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>3.9.5</version>
<executions>
<execution>
<id>unpack-view-resources</id>
<phase>process-resources</phase>
<goals>
<goal>unpack-view-resources</goal>
</goals>
</execution>
<execution>
<id>embeddable-stories</id>
<phase>integration-test</phase>
<configuration>
<includes>
<include>com/example/mymodule/TheStories.java</include>
</includes>
<excludes />
<ignoreFailureInStories>true</ignoreFailureInStories>
<ignoreFailureInView>false</ignoreFailureInView>
<scope>test</scope>
<threads>1</threads>
<metaFilters>
<metaFilter></metaFilter>
</metaFilters>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
</plugin>
I tried this with versions 3.9.5 and 4.0.3, but I get the same error with both versions.
It turns out that the jbehave-maven-plugin was having trouble with log4j. Adding log4j:log4j and org.slf4j:slf4j-log4j as dependencies for the plugin fixed the issue.

tomcat 7 embedded doesn't shutdown correctly ClassNotFoundException ContainerBase$StopChild

I'm trying to make work integration test with Tomcat7 embedded plugin with this config:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>29360</port>
<systemProperties>
<logback.configurationFile>${project.build.testOutputDirectory}/logback-test.xml</logback.configurationFile>
<psw.config>${project.build.testOutputDirectory}</psw.config>
<spring.profiles.active>test-e2e</spring.profiles.active>
</systemProperties>
</configuration>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>run-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war-only</goal>
</goals>
<configuration>
<fork>true</fork>
</configuration>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
However when the shutdown happens, I kept having this error:
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.core.ContainerBase$StopChild
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:49.618s
[INFO] Finished at: Sun Dec 22 07:58:06 CET 2013
[INFO] Final Memory: 163M/259M
[INFO] ------------------------------------------------------------------------
ERROR: IllegalAccessException for stop method in class org.apache.tomcat.maven.plugin.tomcat7.run.ExtendedTomcat
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tomcat.maven.common.run.EmbeddedRegistry.shutdownAll(EmbeddedRegistry.java:110)
at org.apache.tomcat.maven.common.run.EmbeddedRegistry$1.run(EmbeddedRegistry.java:69)
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardServer[-1]]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
at org.apache.catalina.startup.Tomcat.stop(Tomcat.java:351)
... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardService[Tomcat]]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:753)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Tomcat]]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:502)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
... 9 more
Caused by: java.lang.NoClassDefFoundError: org/apache/catalina/core/ContainerBase$StopChild
at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1173)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.core.ContainerBase$StopChild
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)
... 13 more
Process finished with exit code 0
Any tips to correct this ?
If you run mvn integration-test, it won't run the post-integration-test phase, which can lead to this error. Use mvn verify instead.

Maven build: Could not start Tomcat

I am developing web application. In integration testing phase I want to deploy application to tomcat.
I am using maven 2.2.1. Here is my pom configuration:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<path>/${name}</path>
</configuration>
<executions>
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
When running mvn verify -e I get following message:
[INFO] [tomcat7:run {execution: start-tomcat}]
[INFO] Running war on http://localhost:8080/myApp
[INFO] Using existing Tomcat server configuration at /home/user/myApp/target/tomcat
[INFO] create webapp with contextPath: /myApp
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Could not start Tomcat
Embedded error: Failed to start component [StandardServer[-1]]
A child container failed during start
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Could not start Tomcat
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Could not start Tomcat
at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.execute(AbstractRunMojo.java:520)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:335)
at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.startContainer(AbstractRunMojo.java:1091)
at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractRunMojo.execute(AbstractRunMojo.java:512)
... 19 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 22 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 24 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 26 more
[INFO] ------------------------------------------------------------------------
I don't know what I am doing wrong.
target/tomcat/logs/ directory is empty, so I don't know what is happening during startup.
Any ideas how to fix it or get more detailed information what is going wrong?
I guess you've probably resolved this but did you try setting the goal to run-war-only
The port that tomcat generally use is 8080. In your case the console is showing 88080.

Resources