Reputation: 475
Having a problem completing a build after unit tests with maven against a Spring application. I noticed that the mvn install was not completing, and that it appeared to hang after running all the Unit tests. From the cmd line if I run mvn install
I get the tests to complete, but the build hangs
Results :
Tests run: 34, Failures: 0, Errors: 0, Skipped: 0
14:20:15,588 [Thread-3] INFO GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext@10a3b24: 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.springframework.beans.factory.support.DefaultListableBeanFactory@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 org.springframework.context.support.GenericApplicationContext@c5577c: 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.springframework.beans.factory.support.DefaultListableBeanFactory@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
Thats the end of it. Two threads running, not sure what I've done there. Anyway, to troubleshoot I removed all the test and got the program to build completely. If I run mvn install -DskipTests
, I get it to complete. Finally I added one JUnit test that was essentially a system.out.println("hello world");. I could get the installation to run the test and complete the installation by commenting out the JUnit annotation "@RunWith(SpringJUnit4ClassRunner.class)". I'm using Spring 3.1.0.RELEASE.
This problem with the build is from my development machine on Windows7, but our Linux based (Ubuntu 11.10). Hudson CI server successfully runs Maven install on the same project for hourly builds, using the same SVN repository.
Upvotes: 1
Views: 4158
Reputation: 14951
It appears that there is some contention between the threads during Spring app context shutdown. You might try turning up logging for the Spring framework to debug level to see where the contention is, and eliminate it if you can.
If it doesn't appear to be a problem in the app context, another option is to tweak plugin config. The surefire
plugin is used to execute tests, and it has options to run tests in multiple threads. Start by running mvn with -X
to see what values are used for the thread options (parallel, threadCount, perCoreThreadCount, etc.). Tweak the surefire plugin config (execution ID is default-test
) to make sure only one thread is executing and see if you can get the install
working on your Windows 7 box.
Once you have it working in Windows: your current surefire config (which may be the default provided by the super POM) works fine in your CI environment. So I would create a profile, activated if running on the Windows 7 environment, and move the identified surefire plugin config into the profile.
Upvotes: 0
Reputation: 32407
Probably one of your Spring beans is spawning a thread. Use jconsole to connect to the stuck process and see what is hanging about. You can fix it by using @PreDestroy on the offending bean to cancel the thread on shutdown.
Upvotes: 1