Spring integration tests with Team city: OutOfMemoryError

Hello all,

On our project we wanted to start having integration tests with JUnit and Spring's helper classes for integration testing.

http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/test/annotation/AbstractAnnotationAwareTransactionalTests.html

We used the same context files that we use for the application and added some context files to add objects for test data from our model package.

The tests will run on Team city when commited and are disabled by making the Spring method isDisabledInThisEnvironment() from it's test helper classes return true.

http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/test/ConditionalTestCase.html#isDisabledInThisEnvironment%28java.lang.String%29

When we run these tests as enabled on our local envirornment, thet run fine.  However, when we run them on Team City, the context files alone cause an OutOfMemoryError.  We did some diagnosis and realized that if we take away all of the test code that are using the Spring context files for testing, we still get an OutOfMemoryError on Team City.

If we got rid of all of the context files that we wanted to use for integration testing, then Team City would no longer get an OutOfMemoryError.

Is there a way Spring can be configured to do these integration tests without getting an OutOfMemoryError on Team City?  Is there a way to configure Team city so we do not get an OutOfMemoryError using the Spring context files for our integration tests?

6 comments
Comment actions Permalink

Andrew,

What build runner do you use? In Ant runner case could you please try to run tests from the command line using all parameters that TeamCity use (you could find the runner with parameters in teamcity-agent.log) and the same user account.

0
Comment actions Permalink

We were passing command line arguments to increases heap size when running Team City (1024 mb), but were still


having issues.

We have resolved this issue by making one base class that loads the spring contexts and having the other test
classes extend from this one class.  If we have any more classes loading the contexts, then Team city will get an
OutOfMemoryError.
0
Comment actions Permalink

What kind of memory error did you get? Is it heap space error or prm gen space? Also it would be helpful to see build log.

0
Comment actions Permalink

Hello Pavel and Marina.

The log is posted below.

What is very interesting is that below, the cause is supposedly Apache commons logging, which we are not using in the tests added causing the error...

Caused by org.apache.commons.logging.LogConfigurationException: java.lang.OutOfMemoryError


We looked on google and saw we are not the only ones having this issue.  It seems that others have encountered this as well.


==============================================
java.lang.ExceptionInInitializerError
     at org.springframework.validation.BeanPropertyBindingResult.createBeanWrapper(BeanPropertyBindingResult.java:84)
     at org.springframework.validation.BeanPropertyBindingResult.getPropertyAccessor(BeanPropertyBindingResult.java:73)
     at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:78)
     at org.springframework.validation.AbstractBindingResult.rejectValue(AbstractBindingResult.java:177)
     at org.springframework.validation.AbstractBindingResult.rejectValue(AbstractBindingResult.java:161)
     at org.springframework.validation.BindException.rejectValue(BindException.java:129)
     at gov.nyc.doitt.dcla.crms.validation.EnrollmentRequestValidator.validate(EnrollmentRequestValidator.java:52)
     at gov.nyc.doitt.dcla.crms.validation.EnrollmentRequestValidatorTest.testValidateInfo2(EnrollmentRequestValidatorTest.java:61)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:324)
     at junit.framework.TestCase.runTest(TestCase.java:164)
     at junit.framework.TestCase.runBare(TestCase.java:130)
     at junit.framework.TestResult$1.protect(TestResult.java:106)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.framework.TestResult.run(TestResult.java:109)
     at junit.framework.TestCase.run(TestCase.java:120)
     at junit.framework.TestSuite.runTest(TestSuite.java:230)
     at junit.framework.TestSuite.run(TestSuite.java:225)
     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:420)
     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:1339)
     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:831)
     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1785)
     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:785)
     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
     at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:324)
     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     at org.apache.tools.ant.Task.perform(Task.java:348)
     at org.apache.tools.ant.Target.execute(Target.java:357)
     at org.apache.tools.ant.Target.performTasks(Target.java:385)
     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
     at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
     at org.apache.tools.ant.Main.runBuild(Main.java:758)
     at org.apache.tools.ant.Main.startAnt(Main.java:217)
     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.OutOfMemoryError (Caused by java.lang.OutOfMemoryError) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.OutOfMemoryError (Caused by java.lang.OutOfMemoryError))
     at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
     at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
     at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
     at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
     at org.springframework.beans.BeanWrapperImpl.<clinit>(BeanWrapperImpl.java:78)
     ... 41 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.OutOfMemoryError (Caused by java.lang.OutOfMemoryError)
     at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
     at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
     ... 45 more
Caused by: java.lang.OutOfMemoryError

------- Stdout: -------
junit.framework.TestListener: addError(testValidateInfo2, null)

junit.framework.TestListener: endTest(testValidateInfo2)

0
Comment actions Permalink

We increased the permanent generation space and the OutOfMemoryError has gone away...

Thank you for your replis...

0
Comment actions Permalink

I figured out the issue with some helpful hints from Marina and Pavel...

0

Please sign in to leave a comment.