2012-04-25 13 views
1

Springアプリケーションに対してmavenを使用して単体テストを行った後でビルドを完了する際に問題が発生しました。私は、mvnのインストールが完了していないことに気づき、すべてのユニットテストを実行した後にハングアップしたように見えました。 mvn install私が実行した場合、CMDラインから私はテストが完了し得るが、ビルドはそれの終わり厥Spring JUnitテストの実行後にMavenがハングする

Results : 

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

14:20:15,588 [Thread-3] INFO GenericApplicationContext - Closing [email protected]a3b24: startup date [Wed Apr 25 14:20:08 EDT 2012]; root of context hierarchy 
14:20:15,589 [Thread-3] INFO DefaultListableBeanFactory - Destroying singletons in org.s[email protected]16c163f: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,sysModel,alarmList,resourcePool,sysParams,stationHelper,commandTracker,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy 
14:20:15,595 [Thread-7] INFO GenericApplicationContext - Closing [email protected]577c: startup date [Wed Apr 25 14:20:10 EDT 2012]; root of context hierarchy 
14:20:15,596 [Thread-7] INFO DefaultListableBeanFactory - Destroying singletons in org.s[email protected]10952e8: defining beans [alarmDao,purgeDao,xactionDao,dataSource,sysModel,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy 

をハングアップします。 2つのスレッドが実行されている、私はそこで何をしたのか分からない。とにかく、私はすべてのテストを削除し、完全に構築するプログラムを得た解決するために。 mvn install -DskipTestsを実行すると、完了するようになります。最後に、基本的にsystem.out.println( "hello world");というJUnitテストを1つ追加しました。テストを実行し、JUnitの注釈 "@RunWith(SpringJUnit4ClassRunner.class)"をコメントアウトすることでインストールを完了することができます。私はSpring 3.1.0を使用しています。

ビルドに関するこの問題は、Windows7の私の開発マシンからですが、私たちのLinuxベース(Ubuntu 11.10)です。 Hudson CIサーバは、同じSVNリポジトリを使用して、時間プロジェクトのMavenインストールを同じプロジェクトで正常に実行します。

答えて

1

おそらく、あなたのSpring Beanの1つがスレッドを生成しています。 jconsoleを使用してスタックされたプロセスに接続し、何がぶら下がっているかを確認します。問題のあるBeanに対して@PreDestroyを使用して、シャットダウン時にスレッドをキャンセルすることで修正できます。

+1

ええ、手動スレッドの作成を行っているかどうか、または@Asynchronous、またはSpringのタイマー/エグゼキュータコードを使用しているかどうかを確認してください。 – sdouglass

0

Springアプリケーションのコンテキストシャットダウン中にスレッド間に競合が発生しているようです。 Springフレームワークのロギングを有効にして、レベルをデバッグして競合がどこにあるかを確認し、可能であれば排除してみてください。

アプリコンテキストで問題が発生していない場合は、プラグインの設定を調整することもできます。 surefireプラグインはテストの実行に使用され、複数のスレッドでテストを実行するオプションがあります。まず、mvnを-Xで実行して、スレッドオプション(parallel、threadCount、perCoreThreadCountなど)にどの値が使用されているかを確認します。あなたのWindows 7のボックスでinstallが動作するかどうかを確かめるため、surefireプラグインの設定(実行IDはdefault-test)を調整して、ただ1つのスレッドしか実行していないことを確認してください。

Windowsで作業していれば、あなたの現在の確実な設定(スーパーPOMによって提供されるデフォルトの設定かもしれません)は、CI環境で正常に動作します。だから私はprofile, activated if running on the Windows 7 environmentを作成し、特定のsurefireプラグイン設定をプロファイルに移動します。

関連する問題