unit-testingjakarta-eejbosstestngseam

java.lang.IllegalStateException: Already installed InitialContextProperties


I am trying to run a unit test using TestNG with Eclipse (right-click in unit test-> run as TestNg Test). The test fails right away during init phase. I think this is related to testng is loading two different datasources but I have no idea how to fix that. This is the stack trace:

May 15, 2015 11:52:32 AM  org.jboss.seam.microcontainer.TransactionManagerFactory getTransactionManager
INFO: starting JTA transaction manager
May 15, 2015 11:52:32 AM org.jboss.seam.microcontainer.DataSourceFactory getDataSource
INFO: starting Datasource at JNDI name: java:/datasource1
May 15, 2015 11:52:32 AM org.jboss.seam.microcontainer.DataSourceFactory getDataSource
INFO: starting Datasource at JNDI name: java:/DefaultDS
FAILED CONFIGURATION: @BeforeClass init
java.lang.RuntimeException: java.lang.IllegalStateException: Already installed InitialContextProperties
at com.pinncorp.mock.SeamTest.startJbossEmbeddedIfNecessary(SeamTest.java:223)
at org.jboss.seam.mock.AbstractSeamTest.startSeam(AbstractSeamTest.java:915)
at com.pinncorp.mock.SeamTest.init(SeamTest.java:133)
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:597)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:17

Thanks in advance...


Solution

  • I would suggest please clear all the build path and testng libraries, clean your project and start afresh, it would certainly work. if not try it in different workspace altogether.