class weblogic.management.WeblogicMBean not found - ant

I meet this problem when I try to run Junit test case in fork mode (starting each test in a separate JVM) using Build ant file.
[junit] Exception in thread "main" java.lang.NoClassDefFoundError:
weblogic/management/WebLogicMBean [junit] at
java.lang.ClassLoader.defineClass1(Native Method) [junit] at
java.lang.ClassLoader.defineClass(ClassLoader.java:621) [junit] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
[junit] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:260) [junit]
at java.net.URLClassLoader.access$000(URLClassLoader.java:56) [junit]
at java.net.URLClassLoader$1.run(URLClassLoader.java:195) [junit] at
java.security.AccessController.doPrivileged(Native Method) [junit] at
java.net.URLClassLoader.findClass(URLClassLoader.java:188) [junit] at
java.lang.ClassLoader.loadClass(ClassLoader.java:307) [junit] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) [junit]
at java.lang.ClassLoader.loadClass(ClassLoader.java:252) [junit] at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) [junit]
at java.lang.ClassLoader.defineClass1(Native Method) [junit] at
java.lang.ClassLoader.defineClass(ClassLoader.java:621) [junit] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
[junit] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:260) [junit]
at java.net.URLClassLoader.access$000(URLClassLoader.java:56) [junit]
at java.net.URLClassLoader$1.run(URLClassLoader.java:195) [junit] at
java.security.AccessController.doPrivileged(Native Method) [junit] at
java.net.URLClassLoader.findClass(URLClassLoader.java:188) [junit] at
java.lang.ClassLoader.loadClass(ClassLoader.java:307) [junit] at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) [junit]
at java.lang.ClassLoader.loadClass(ClassLoader.java:252) [junit] at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) [junit]
at java.lang.ClassLoader.defineClass1(Native Method) [junit] at
java.lang.ClassLoader.defineClass(ClassLoader.java:621) [junit] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
[junit] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:260) [junit]
at java.net.URLClassLoader.access$000(URLClassLoader.java:56) [junit]
at java.net.URLClassLoader$1.run(URLClassLoader.java:195) ....
I have the library weblogic.jar in my build library folders, which is set as classpath for the junit task. I look at this file and can't find the WeblogicMBean.class inside.
However, in Jdev, I can import weblogic.management.WeblogicMBean into my class if I set library reference to this weblogic.jar file and compile my class without problem.
Any suggestion of what really goes wrong?
Thanks a lot.

NoClassDefFoundError usually means the correct version of the class was not found at runtime.
Since your compile is fine, does your CLASSPATH at compile time refer to the same jar as at runtime?
Also check if there are multiple weblogic.jar in the runtime CLASSPATH for JUnit.
Whats your version of weblogic, the class is in the weblogic.jar for version 9 at least.

Related

JUnit/Ant in Hudson: How to start tests in headless mode?

I am having trouble with setting up unit tests for a project developed under Netbeans in Hudson. So far, Hudson is running fine, monitoring my git repository, and automatically starting builds.
But when building is finished, Hudson starts the unit tests. And here lies the problem: Some classes use awt, and when started from within Hudson, the tests fail like this:
[junit] Testcase: testParse_SimpleTextAndSymbols(com.dua3.util.text.LatexParserTest): Caused an ERROR
[junit] Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
[junit] java.lang.InternalError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
[junit] at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
[junit] at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
[junit] at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:110)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:190)
[junit] at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)
[junit] at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
[junit] at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:119)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:190)
[junit] at java.awt.Toolkit$2.run(Toolkit.java:868)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:860)
[junit] at sun.swing.SwingUtilities2.getSystemMnemonicKeyMask(SwingUtilities2.java:1877)
[junit] at javax.swing.plaf.basic.BasicLookAndFeel.initComponentDefaults(BasicLookAndFeel.java:752)
[junit] at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:434)
[junit] at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:148)
[junit] at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1589)
[junit] at javax.swing.UIManager.setLookAndFeel(UIManager.java:536)
[junit] at javax.swing.UIManager.setLookAndFeel(UIManager.java:576)
[junit] at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1345)
[junit] at javax.swing.UIManager.initialize(UIManager.java:1455)
[junit] at javax.swing.UIManager.maybeInitialize(UIManager.java:1422)
[junit] at javax.swing.UIManager.getLookAndFeelDefaults(UIManager.java:1034)
[junit] at com.dua3.util.graph.javase.swing.SwingFont$SwingFontProvider.getDefaultFont(SwingFont.java:50)
[junit] at com.dua3.util.graph.Font.getDefault(Font.java:52)
[junit] at com.dua3.util.text.LatexParser$Settings.<init>(LatexParser.java:39)
[junit] at com.dua3.util.text.LatexParser.parse(LatexParser.java:61)
[junit] at com.dua3.util.text.LatexParserTest.testParse_SimpleTextAndSymbols(LatexParserTest.java:49)
I thought it should be enough to check GraphicsEnvironment.isHeadless(), but obviously it isn't. This is the code snippet were it goes wrong:
if(!GraphicsEnvironment.isHeadless()) {
final UIDefaults lookAndFeelDefaults = UIManager.getLookAndFeelDefaults(); // SwingFont.java:50
if (lookAndFeelDefaults!=null) {
swingFont = lookAndFeelDefaults.getFont("defaultFont");
}
}
I tried in the following in Hudson:
Setting Java Options to -Djava.awt.headless=true in the "Build" section
Entering a line "java.awt.headless=true" in the Build Properties
All of that doesn't work. It seems those are only passed on to ant, but not onwards when invoking java to run the JUnit tests.
Is there any way to tell ant that I want my tests be run in headless mode?
I spend some time looking for this and finally found the answer. In short: setting java.awt.headless=true is not enough on linux. You have to unset DISPLAY. So, go to "Manage Hudson", "Configure System", make sure "Environment variables" is checked under "Global Properties" and add a new variable of name DISPLAY (leave the value field blank).

Junit - Ant - Soap UI and Data File

I am trying to run a basic REST Web Service Test calling a Soap UI project from JUnit in ANT.
Everything compiles correctly and runs, however when I try to run a test that uses an external data file I get the error:
Unable to obtain resource from C:\soapTest\atmTest3.csv:
java.util.zip.ZipException: error in opening zip file
[junit] Unable to obtain resource from C:\soapTest\atmTest3.csv:
I have already searched and seen others who have had the problem with classes and tried to only include what I believe I need. This is how I include my data file in my build.xml
<path id ="test.input.dir" >
<pathelement path="C:\soapTest\atmTest3.csv" />
</path>
<path id="classpath.junittest">
<path refid="test.input.dir" />
<path refid="jars.dir" />
</path>
My JUNIT method is very basic
public void testRunner() throws Exception
{
SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
runner.setProjectFile("C:/soapTest/ATM-Locator-soapui-project.xml");
runner.run();
}
Has anyone had success using an external datasource file and running in JUNIT?
Are there alternatives?
------------------ ANT Output below -------------------
Building in workspace C:\JENKINS_PROJECTS\workspace\JUNIT_Test
[JUNIT_Test] $ cmd.exe /C '"C:\apache-ant-1.9.3\bin\ant.bat -D-Verbose="" -D-Debug="" && exit %%ERRORLEVEL%%"'
Buildfile: C:\JENKINS_PROJECTS\workspace\JUNIT_Test\build.xml
[echo] Apache Ant version is Apache Ant(TM) version 1.9.3 compiled on December 23 2013
[echo] Apache basedir is C:\JENKINS_PROJECTS\workspace\JUNIT_Test
compile:
[javac] Compiling 2 source files to C:\JENKINS_PROJECTS\workspace\JUNIT_Test\classes
compile-test:
[javac] Compiling 6 source files to C:\JENKINS_PROJECTS\workspace\JUNIT_Test\classes
test:
[junit] Running com.JUnit.AllTests
[junit] Testsuite: com.JUnit.AllTests
Unable to obtain resource from C:\soapTest\atmTest3.csv: java.util.zip.ZipException: error in opening zip file
[junit] Unable to obtain resource from C:\soapTest\atmTest3.csv:
[junit] java.util.zip.ZipException: error in opening zip file
[junit] at java.util.zip.ZipFile.open(Native Method)
[junit] at java.util.zip.ZipFile.<init>(Unknown Source)
[junit] at java.util.jar.JarFile.<init>(Unknown Source)
[junit] at java.util.jar.JarFile.<init>(Unknown Source)
[junit] at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1006)
[junit] at org.apache.tools.ant.AntClassLoader.getResource(AntClassLoader.java:887)
[junit] at org.apache.log4j.helpers.Loader.getResource(Loader.java:96)
[junit] at org.apache.log4j.LogManager.<clinit>(LogManager.java:103)
[junit] at org.apache.log4j.Logger.getLogger(Logger.java:117)
[junit] at com.eviware.soapui.SoapUI.<clinit>(SoapUI.java:135)
[junit] at com.eviware.soapui.tools.SoapUITestCaseRunner.<clinit>(SoapUITestCaseRunner.java:79)
[junit] at com.util.ParameterATM_Test.testRunner(Unknown Source)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[junit] at java.lang.reflect.Method.invoke(Unknown Source)
[junit] at junit.framework.TestCase.runTest(TestCase.java:168)
[junit] at junit.framework.TestCase.runBare(TestCase.java:134)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:110)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:128)
[junit] at junit.framework.TestResult.run(TestResult.java:113)
[junit] at junit.framework.TestCase.run(TestCase.java:124)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:243)
[junit] at junit.framework.TestSuite.run(TestSuite.java:238)
[junit] at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
[junit] at org.junit.runners.Suite.runChild(Suite.java:128)
[junit] at org.junit.runners.Suite.runChild(Suite.java:24)
[junit] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
[junit] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
[junit] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
[junit] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
[junit] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
[junit] at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
[junit] at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:532)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:1425)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:852)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1904)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:804)
[junit] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[junit] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[junit] at java.lang.reflect.Method.invoke(Unknown Source)
[junit] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[junit] at org.apache.tools.ant.Task.perform(Task.java:348)
[junit] at org.apache.tools.ant.Target.execute(Target.java:435)
[junit] at org.apache.tools.ant.Target.performTasks(Target.java:456)
[junit] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
[junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
[junit] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
[junit] at org.apache.tools.ant.Main.runBuild(Main.java:851)
[junit] at org.apache.tools.ant.Main.startAnt(Main.java:235)
[junit] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[junit] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

hsqldb inmemory ant target junit test

I have defined an Ant target containing in-memory HSQLDB:
<target name="create.tables" depends="-prepare.test">
<property name="db.connection.url" value="jdbc:hsqldb:mem:adb"/>
<property name="db.driver" value="org.hsqldb.jdbcDriver"/>
<property name="db.username" value="a"/>
<property name="db.password" value="a"/>
<echo>Creating tables using: ${db.driver} ${db.connection.url} ${product.mysql-connector.jar}</echo>
<sql driver="${db.driver}"
url="${db.connection.url}"
userid="${db.username}"
password="${db.password}"
onerror="stop"
src="/create-schema.sql">
<classpath refid="test.classpath" />
</sql>
</target>
The prepare.test only contains basic things such as fileset etc.
When I print the SQL inserts everything is OK. But how can I access the in-memory HSQLDB from a JUnit testcase?
I tried:
Class.forName("org.hsqldb.jdbcDriver");
connection = DriverManager.getConnection("jdbc:hsqldb:mem:adb",
"a", "a");
but there was only an empty database. Is it possible to use HSQLDB with the insert statements from the Ant target in JUnit testcases?
The exception in the junit test is as follows. The table exists because it is created in the ant task:
[junit] java.lang.Exception: user lacks privilege or object not found: MYTABLE
[junit] at com.inmemorytests.InMemoryTest.testSomething(InMemoryTest.java:116)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[junit] at java.lang.reflect.Method.invoke(Method.java:601)
[junit] at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
[junit] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
[junit] at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
[junit] at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
[junit] at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
[junit] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
[junit] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
[junit] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
[junit] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
[junit] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
[junit] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
[junit] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
[junit] at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
[junit] at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:518)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:906)
This is your connection URL in Ant:
<property name="db.connection.url" value="jdbc:hsqldb:mem:adb"/>
You must use the same URL and the same username and password for a connection:
connection = DriverManager.getConnection("jdbc:hsqldb:mem:adb", "a", "a");
Update: When using a memory database, the Ant target and the JUnit tests must run in the same JVM. If you are running the two in separate JVM's, start an HSQLDB server before the tests and connect to this server from each test. The server connection URL's are different and described in the HSQLDB Guide.

java.lang.OutOfMemoryError: Java heap space on my ant junit task even when I have setted maxmemory="1024m"

I am having an issue with my junit task. When I run it from eclipse, it goes well with the -Xmx1000m argument. It was working too in my ant task to but suddenly it stop working, throwing this out of memory exception. I have configured the maxmemory="1024m" on the ant task but with no success.
Here's the stack trace:
[junit] java.lang.IllegalStateException: Failed to load ApplicationContext
[junit] at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
[junit] at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
[junit] at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
[junit] at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
[junit] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
[junit] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
[junit] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
[junit] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
[junit] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
[junit] at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
[junit] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
[junit] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
[junit] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
[junit] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
[junit] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
[junit] at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
[junit] at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
[junit] at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
[junit] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
[junit] at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:420)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:1339)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:831)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1785)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:785)
[junit] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[junit] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:597)
[junit] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[junit] at org.apache.tools.ant.Task.perform(Task.java:348)
[junit] at org.apache.tools.ant.Target.execute(Target.java:357)
[junit] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[junit] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
[junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
[junit] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[junit] at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
[junit] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423)
[junit] at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137)
[junit] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'streamingCotizacionesDAO' defined in class path resource [applicationContext-core-Dao.xml]: Cannot resolve reference to bean 'hibernateTemplateSeguro' while setting bean property 'hibernateTemplateSeguro'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplateSeguro' defined in class path resource [applicationContext-dataAccess.xml]: Cannot resolve reference to bean 'sessionFactorySeguro' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactorySeguro' defined in class path resource [applicationContext-dataAccess.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: Java heap space
[junit] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
[junit] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
[junit] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
[junit] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
[junit] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
[junit] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
[junit] at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
[junit] at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
[junit] at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
[junit] at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
[junit] ... 39 more
[junit] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplateSeguro' defined in class path resource [applicationContext-dataAccess.xml]: Cannot resolve reference to bean 'sessionFactorySeguro' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactorySeguro' defined in class path resource [applicationContext-dataAccess.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: Java heap space
[junit] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
[junit] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
[junit] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
[junit] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
[junit] ... 55 more
[junit] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactorySeguro' defined in class path resource [applicationContext-dataAccess.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: Java heap space
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
[junit] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
[junit] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
[junit] ... 65 more
[junit] Caused by: java.lang.OutOfMemoryError: Java heap space
[junit] at java.util.Arrays.copyOf(Arrays.java:2882)
[junit] at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
[junit] at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
[junit] at java.lang.StringBuffer.append(StringBuffer.java:224)
[junit] at org.hibernate.sql.Select.toStatementString(Select.java:68)
[junit] at org.hibernate.loader.collection.BasicCollectionJoinWalker.initStatementString(BasicCollectionJoinWalker.java:128)
[junit] at org.hibernate.loader.collection.BasicCollectionJoinWalker.<init>(BasicCollectionJoinWalker.java:62)
[junit] at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:53)
[junit] at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:40)
[junit] at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:31)
[junit] at org.hibernate.loader.collection.BatchingCollectionInitializer.createBatchingCollectionInitializer(BatchingCollectionInitializer.java:92)
[junit] at org.hibernate.persister.collection.BasicCollectionPersister.createCollectionInitializer(BasicCollectionPersister.java:297)
[junit] at org.hibernate.persister.collection.AbstractCollectionPersister.postInstantiate(AbstractCollectionPersister.java:541)
[junit] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
[junit] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
[junit] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)
[junit] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)
[junit] at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$5.run(AbstractAutowireCapableBeanFactory.java:1467)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1465)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
[junit] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
[junit] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
[junit] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)

How to integrate SWTBot test in Jenkins CI?

I've got a SWT application (not Eclipse RCP based) and I currently test it using SWTBot. This works fine while running the tests from Eclipse. I'm using ant as buildsystem.
On Jenkins the tests fail - an exception is thrown
[junit] Testcase: testPasswordChange(de.rssit.kgepc.swtbot.ChangePasswordTest): Caused an ERROR
[junit] null
[junit] java.lang.ExceptionInInitializerError
[junit] at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeCharacter(Keyboard.java:100)
[junit] at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.typeText(Keyboard.java:89)
[junit] at org.eclipse.swtbot.swt.finder.widgets.SWTBotText.typeText(SWTBotText.java:92)
[junit] at org.eclipse.swtbot.swt.finder.widgets.SWTBotText.typeText(SWTBotText.java:78)
[junit] at de.foo.swtbot.pages.PasswordDialogPage.setText(PasswordDialogPage.java:70)
[junit] at de.foo.swtbot.pages.PasswordDialogPage.setOldPassword(PasswordDialogPage.java:30)
[junit] at de.foo.swtbot.ChangePasswordTest.testPasswordChange(ChangePasswordTest.java:43)
[junit] at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getKeyboardLayout(KeyboardLayout.java:89)
[junit] at org.eclipse.swtbot.swt.finder.keyboard.KeyboardLayout.getDefaultKeyboardLayout(KeyboardLayout.java:75)
[junit] at org.eclipse.swtbot.swt.finder.keyboard.Keystrokes.<clinit>(Keystrokes.java:110)
Searching for this specific problem did not result in any helpful solution.
Edit:
Adding the jvm args to set US english fixes this isse and makes some tests run; all other bring the following stacktrace:
[junit] Running foo.bar.swtbot.ChangePasswordTest
[junit] Testsuite: foo.bar.swtbot.ChangePasswordTest
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 1.453 sec
[junit] Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 1.453 sec
[junit]
[junit] Testcase: testPasswordChange(foo.bar.swtbot.ChangePasswordTest): FAILED
[junit] null
[junit] junit.framework.AssertionFailedError: null
[junit] at foo.bar.swtbot.ChangePasswordTest.testPasswordChange(ChangePasswordTest.java:46)
[junit]
[junit]
[junit] Cobertura: Loaded information on 219 classes.
[junit] Cobertura: Saved information on 219 classes.
[junit] Test foo.bar.swtbot.ChangePasswordTest FAILED
[junit] Running foo.bar.swtbot.LoginDialogTest
[junit] Testsuite: foo.bar.swtbot.LoginDialogTest
[junit] Exception in thread "UIThread" org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4282)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4197)
[junit] at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
[junit] at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
[junit] at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
[junit] at foo.bar.swtbot.UIThread$1.run(UIThread.java:79)
[junit] at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
[junit] at foo.bar.swtbot.UIThread.startEventLoop(UIThread.java:74)
[junit] at foo.bar.swtbot.UIThread.run(UIThread.java:59)
[junit] Caused by: org.eclipse.swt.SWTException: Widget is disposed
[junit] at org.eclipse.swt.SWT.error(SWT.java:4282)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4197)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4168)
[junit] at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
[junit] at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340)
[junit] at org.eclipse.swt.widgets.Control.setVisible(Control.java:3725)
[junit] at foo.bar.gui.Main.tryLogin(Main.java:142)
[junit] at foo.bar.gui.Main.open(Main.java:117)
[junit] at foo.bar.swtbot.AbstractMainTest$1.run(AbstractMainTest.java:46)
[junit] at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
[junit] at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
[junit] ... 6 more
[junit] Exception in thread "Timer-0" org.eclipse.swt.SWTException: Widget is disposed
[junit] at org.eclipse.swt.SWT.error(SWT.java:4282)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4197)
[junit] at org.eclipse.swt.SWT.error(SWT.java:4168)
[junit] at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
[junit] at org.eclipse.swt.widgets.Widget.getDisplay(Widget.java:582)
[junit] at foo.bar.gui.AbstractKGEAdminDialog$1.run(AbstractKGEAdminDialog.java:46)
[junit] at java.util.TimerThread.mainLoop(Timer.java:512)
[junit] at java.util.TimerThread.run(Timer.java:462)
Regarding java.lang.ExceptionInInitializerError
I notice that there are / have been Eclipse bugs relating to missing keyboard layout for DE_DE locale. Could I suggest you check the locale settings of the process running the junit tests. If you set the locale to en_US, does the problem still arise?
Apart from setting the locale for the server process (e.g. LC_ALL environment variable?), perhaps you could use explicit locale in your junit task, e.g.
<junit fork="yes">
<jvmarg value="-Duser.language=en"/>
<jvmarg value="-Duser.region=US"/>
Regarding org.eclipse.swt.SWTException: Widget is disposed
Maybe this is exposing a real bug in your UI code, but I suspect you need to look at your unit tests. Are they stateless, or do they depend on a certain execution order to work reliably? Perhaps this error can arise if the tests are executed in a different order than you expect.

Resources