Maven / Jetty - 在集成测试期间启动Jetty服务器

时间:2018-01-18 10:14:42

标签: java maven selenium jetty

我正在尝试为CI / CD流程添加一些集成测试。我已经创建了一个非常基本的selenium测试,我想在构建过程中在localhost上的Jetty服务器上运行。

当我正在运行'mvn verify'时,我可以告诉它在maven周期中尝试启动Jetty,这是在cmd中记录的:

INFO] >>> jetty-maven-plugin:9.0.7.v20131107:start (start-jetty) > validate @ ibis-adapterframework-webapp >>>
[INFO]
[INFO] <<< jetty-maven-plugin:9.0.7.v20131107:start (start-jetty) < validate @ ibis-adapterframework-webapp <<<
[INFO]
[INFO]
[INFO] --- jetty-maven-plugin:9.0.7.v20131107:start (start-jetty) @ ibis-adapterframework-webapp ---
[INFO] Configuring Jetty for project: Ibis AdapterFramework webapp
[INFO] webAppSourceDirectory not set. Trying src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes directory C:\Users\Laurens\Documents\iaf\iaf\webapp\target\classes does not exist
[INFO] Context path = /
[INFO] Tmp directory = C:\Users\Laurens\Documents\iaf\iaf\webapp\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = file:/C:/Users/Laurens/Documents/iaf/iaf/webapp/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = C:\Users\Laurens\Documents\iaf\iaf\webapp\src\main\webapp
[INFO] jetty-9.0.7.v20131107

在上述之后,我收到警告和nullpointerexception ......

这是我的pom.xml

<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.20.1</version>
    <executions>
        <execution>
          <id>integration-test</id>
          <goals>
            <goal>integration-test</goal>
          </goals>
        </execution>
        <execution>
          <id>verify</id>
          <goals>
            <goal>verify</goal>
          </goals>
        </execution>
     </executions>
  </plugin>
  <plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.0.7.v20131107</version>
    <configuration>
      <systemProperties>
        <systemProperty>
          <name>application.server.type</name>
          <value>JETTYMVN</value>
        </systemProperty>
        <systemProperty>
          <name>log.dir</name>
          <value>target</value>
        </systemProperty>
        <systemProperty>
          <name>log.level</name>
          <value>DEBUG</value>
        </systemProperty>
        <systemProperty>
          <name>otap.stage</name>
          <value>LOC</value>
        </systemProperty>
      </systemProperties>
    <stopPort>8005</stopPort>
    <stopKey>STOP</stopKey>
    <httpConnector>
        <port>8080</port>
    </httpConnector>
    <webApp>
        <contextPath>/</contextPath>
    </webApp>
    </configuration>
    <executions>
        <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start</goal>
            </goals>
            <configuration>
                <scanIntervalSeconds>0</scanIntervalSeconds>
                <daemon>true</daemon>
            </configuration>
        </execution>
        <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
  </plugin>
</plugins>
</build>

这是堆栈跟踪:

Ibis LogUtil class did not find DeploymentSpecifics.properties, leaving it up to log4j's default initialization procedure: http://logging.apache.org/log4j/docs/manual.html#defaultInit
[WARNING] unavailable
java.lang.NullPointerException
    at nl.nn.adapterframework.util.Misc.getBuildOutputDirectory (Misc.java:932)
    at nl.nn.adapterframework.util.Misc.getProjectBaseDir (Misc.java:943)
    at nl.nn.adapterframework.webcontrol.ConfigurationServlet.init (ConfigurationServlet.java:62)
    at javax.servlet.GenericServlet.init (GenericServlet.java:244)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet (ServletHolder.java:540)
    at org.eclipse.jetty.servlet.ServletHolder.initialize (ServletHolder.java:349)
    at org.eclipse.jetty.servlet.ServletHandler.initialize (ServletHandler.java:812)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:288)
    at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1322)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:732)
    at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:490)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:281)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:118)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:60)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart (ContextHandlerCollection.java:155)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:118)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:60)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:118)
    at org.eclipse.jetty.server.Server.start (Server.java:342)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:60)
    at org.eclipse.jetty.server.Server.doStart (Server.java:290)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart (JettyServer.java:68)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty (AbstractJettyMojo.java:564)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute (AbstractJettyMojo.java:360)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:168)
    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:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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)
[WARNING] Failed startup of context o.e.j.m.p.JettyWebAppContext@7e79541d{/,file:/C:/Users/Laurens/Documents/iaf/iaf/webapp/src/main/webapp/,STARTING}{file:/C:/Users/Laurens/Documents/iaf/iaf/webapp/src/main/webapp/}
javax.servlet.ServletException: ConfigurationServlet@dd64c88f==nl.nn.adapterframework.webcontrol.ConfigurationServlet,0,false
    at org.eclipse.jetty.servlet.ServletHolder.initServlet (ServletHolder.java:561)
    at org.eclipse.jetty.servlet.ServletHolder.initialize (ServletHolder.java:349)
    at org.eclipse.jetty.servlet.ServletHandler.initialize (ServletHandler.java:812)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:288)
    at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1322)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:732)
    at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:490)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:281)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:118)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:60)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart (ContextHandlerCollection.java:155)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:118)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:60)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:118)
    at org.eclipse.jetty.server.Server.start (Server.java:342)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:60)
    at org.eclipse.jetty.server.Server.doStart (Server.java:290)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart (JettyServer.java:68)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty (AbstractJettyMojo.java:564)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute (AbstractJettyMojo.java:360)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:168)
    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:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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: java.lang.NullPointerException
    at nl.nn.adapterframework.util.Misc.getBuildOutputDirectory (Misc.java:932)
    at nl.nn.adapterframework.util.Misc.getProjectBaseDir (Misc.java:943)
    at nl.nn.adapterframework.webcontrol.ConfigurationServlet.init (ConfigurationServlet.java:62)
    at javax.servlet.GenericServlet.init (GenericServlet.java:244)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet (ServletHolder.java:540)
    at org.eclipse.jetty.servlet.ServletHolder.initialize (ServletHolder.java:349)
    at org.eclipse.jetty.servlet.ServletHandler.initialize (ServletHandler.java:812)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:288)
    at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1322)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:732)
    at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:490)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:281)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:118)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:60)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart (ContextHandlerCollection.java:155)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:118)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:60)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:118)
    at org.eclipse.jetty.server.Server.start (Server.java:342)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:100)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:60)
    at org.eclipse.jetty.server.Server.doStart (Server.java:290)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart (JettyServer.java:68)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:69)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty (AbstractJettyMojo.java:564)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute (AbstractJettyMojo.java:360)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:168)
    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:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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)
[WARNING] !RequestLog

但是在巨大的堆栈跟踪之后,它的日志记录:

Started ServerConnector@622b87e8{HTTP/1.1}{0.0.0.0:8080}
[INFO] Started Jetty Server
[INFO]
[INFO] --- maven-failsafe-plugin:2.20.1:integration-test (integration-test) @ ibis-adapterframework-webapp ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- jetty-maven-plugin:9.0.7.v20131107:stop (stop-jetty) @ ibis-adapterframework-webapp ---

这很奇怪,因为它没有运行任何测试...我的测试位于:

web应用程序的\ src \测试\ java中\ NL \ン\ adapterframework \夏精\ API

我的测试是根据命名约定命名的,它叫做ChromeTestIT.java

为什么会发生这种情况以及我可以做些什么来阻止它? 提前谢谢!

1 个答案:

答案 0 :(得分:0)

nl.nn.adapterframework.webcontrol.ConfigurationServlet引发异常导致启动/部署问题。

webapp从未部署过。

无法进行任何测试。