Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does jetty server hangs after server start and doesn't run integration test?

I am running integration test using maven-jetty-plugin and maven-failsafe-plugin. Here's my configuration:

   <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.7.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.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>6.1.26</version>
            <configuration>

                  <connectors>
                    <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                      <port>8080</port>
                      <maxIdleTime>3600000</maxIdleTime>
                    </connector>
                  </connectors>

                <contextPath>/</contextPath>
                <scanIntervalSeconds>3</scanIntervalSeconds>
                <scanTargetPatterns>
                    <scanTargetPattern>
                        <directory>src/main/webapp/WEB-INF</directory>
                        <excludes>
                            <exclude>**/*.jsp</exclude>
                            <exclude>**/*.html</exclude>
                        </excludes>
                        <includes>
                            <include>**/*.page</include>
                            <include>**/*.properties</include>
                            <include>**/*.xml</include>
                        </includes>
                    </scanTargetPattern>
                </scanTargetPatterns>
            </configuration>
            <executions>
                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                          <goal>run-war</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>

When i run mvn clean install, jetty server starts and after that nothing happens (it gets stuck). Last line in my logs is : [INFO] Started Jetty Server. When i press control-c, here is what it prints:

2013-04-25 15:24:16.315:INFO::Shutdown hook executing
2013-04-25 15:24:16.317:INFO::Stopped [email protected]:8080
2013-04-25 15:24:16.821:INFO:/ca-app:Shutting down log4j
2013-04-25 15:24:16.821:INFO:/ca-app:Closing Spring root WebApplicationContext
2013-04-25 15:24:22.108:INFO::Shutdown hook complete[INFO] 
Jetty server exiting.
[INFO] 
[INFO] --- maven-failsafe-plugin:2.7.1:integration-test (default) @ my-app ---
[INFO] Failsafe report directory: my-app/target/failsafe-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO] 
[INFO] --- maven-jetty-plugin:6.1.26:stop (stop-jetty) @ my-app ---
[INFO] 
[INFO] --- maven-failsafe-plugin:2.7.1:verify (default) @ my-app ---
[INFO] Killing Jetty
[INFO] Failsafe report directory: my-app/target/failsafe-reports
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ my-app ---
[INFO] Installing my-app/target/ca-app-0.1.5-SNAPSHOT.war to ~/.m2/....../my-app/0.1.5-SNAPSHOT/my-app-0.1.5-SNAPSHOT.war
[INFO] Installing my-app/pom.xml to ~/.m2/....../my-app/0.1.5-SNAPSHOT/my-app-0.1.5-SNAPSHOT.war
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:sources (install) @ my-app ---

Why does it get stuck? When i press control-c, why does it perform rest of the steps? How can i fix it?

like image 421
Tarun Kumar Avatar asked Apr 25 '13 10:04

Tarun Kumar


1 Answers

Try using start instead of run-war.

From javadoc on org\eclipse\jetty\jetty-maven-plugin\9.3.0.M2\jetty-maven-plugin-9.3.0.M2.jar!\org\eclipse\jetty\maven\plugin\AbstractJettyMojo.nonblocking


Determines whether or not the server blocks when started. The default behavior (false) will cause the server to pause other processes while it continues to handle web requests. This is useful when starting the server with the intent to work with it interactively. This is the behaviour of the jetty:run, jetty:run-war, jetty:run-war-exploded goals. If true, the server will not block the execution of subsequent code. This is the behaviour of the jetty:start and default behaviour of the jetty:deploy goals.


like image 145
Altair7852 Avatar answered Oct 22 '22 02:10

Altair7852