2013-04-25 38 views
7

Tôi đang chạy thử nghiệm tích hợp bằng cách sử dụng plugin maven-jetty-plugin và maven-failsafe. Dưới đây là cấu hình của tôi:Tại sao máy chủ jetty bị treo sau khi máy chủ khởi động và không chạy thử nghiệm tích hợp?

<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> 

Khi tôi chạy mvn clean install, bắt đầu cầu cảng máy chủ và sau đó không có gì xảy ra (nó bị mắc kẹt). Dòng cuối cùng trong nhật ký của tôi là: [INFO] Đã bắt đầu Máy chủ Jetty. Khi tôi nhấn control-c, dưới đây là những gì nó in:

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 --- 

Tại sao nó bị kẹt? Khi tôi nhấn control-c, tại sao nó thực hiện các bước còn lại? Làm thế nào tôi có thể sửa chữa nó?

+0

câu hỏi tương tự là: http://stackoverflow.com/questions/4759620/integration-tests-willnt-start-failsafe-maven? rq = 1. Có người hỏi đã nhận xét rằng việc thay đổi phiên bản không chắc chắn-không an toàn đã khắc phục được vấn đề cho anh ta. Nhưng, nó không có vẻ là làm việc cho tôi. Tôi cũng đã bình luận. –

+0

Mọi trợ giúp sẽ được đánh giá cao. –

Trả lời

1

Hãy thử sử dụng bắt đầu thay vì chạy chiến tranh.

Từ javadoc trên 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


Xác định có hay không các khối máy chủ khi bắt đầu. Hành vi mặc định (sai) sẽ khiến máy chủ tạm dừng các quá trình khác trong khi nó tiếp tục xử lý các yêu cầu web. Điều này rất hữu ích khi khởi động máy chủ với ý định làm việc với nó một cách tương tác. Đây là hành vi của cầu cảng : chạy, cầu cảng: chạy chiến tranh, cầu cảng: các mục tiêu chạy trong chiến tranh bùng nổ. Nếu đúng, máy chủ sẽ không chặn việc thực thi mã tiếp theo. Đây là hành vi của cầu cảng : bắt đầu và hành vi mặc định của cầu cảng : triển khai mục tiêu.


0

Vì vậy, để bắt đầu cầu tàu add chạy:

<goals> 
    <goal>stop</goal> 
     <goal>start</goal> 
</goals> 

Và toàn bộ:

<plugin> 
    <groupId>org.eclipse.jetty</groupId> 
    <artifactId>jetty-maven-plugin</artifactId> 
    <version>9.2.10.v20150310</version> 
    <configuration> 
     <war>webapp/target/MyWar.war</war> 
     <stopKey>fooKey</stopKey> 
     <stopPort>8081</stopPort> 
     <stopWait>1</stopWait> 
     <httpConnector> 
      <port>8888</port> 
     </httpConnector> 
    </configuration> 
    <executions> 
     <execution> 
      <id>start-jetty</id> 
      <phase>pre-integration-test</phase> 
      <goals> 
       <goal>stop</goal> 
       <goal>start</goal> 
      </goals> 
      <configuration> 
       <scanIntervalSeconds>0</scanIntervalSeconds> 
       <daemon>true</daemon> 
       <stopKey>STOP</stopKey> 
       <stopPort>8866</stopPort> 
      </configuration> 
     </execution> 
     <execution> 
      <id>stop-jetty</id> 
      <phase>post-integration-test</phase> 
      <goals> 
       <goal>stop</goal> 
      </goals> 
      <configuration> 
       <scanIntervalSeconds>0</scanIntervalSeconds> 
       <daemon>true</daemon> 
       <stopKey>STOP</stopKey> 
       <stopPort>8866</stopPort> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
Các vấn đề liên quan