Integration Testing with two WARs in EAR: "No application context active"
maticomp Jan 9, 2011 8:13 PMHello!
I'm using Seam GA 2.2.1 with Maven project by seam-maven-refimpl. The reference implementation builds fine and tests fine (it uses OpenEJB instead of JBoss Embedded).
My project has evolved into two WARs in one EAR which are supported by Seam 2.2.0 correctly and everything works fine under deployment. I have trouble testing in this setting though.
public class ItemTest extends SeamOpenEjbTest { @Test public void countItems() throws Exception { new FacesRequest("/test.xhtml") { @Override protected void renderResponse() { assert getValue("#{items.rowCount}").equals(4) : "Wrong items number"; } }.run(); } }
I have a very simple test case, almost identical with tests provided with seam-maven-refimpl. Unfortunately, it results in:
java.lang.IllegalStateException: No application context active at org.jboss.seam.Component.forName(Component.java:1945) at org.jboss.seam.Component.getInstance(Component.java:2005) at org.jboss.seam.Component.getInstance(Component.java:1983) at org.jboss.seam.Component.getInstance(Component.java:1977) at org.jboss.seam.Component.getInstance(Component.java:1972) at pl.lodz.p.zsk.koffeine.zapisyseam.action.ItemTest.countItems(ItemTest.java:38) 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.MethodHelper.invokeMethod(MethodHelper.java:641) at org.testng.internal.Invoker.invokeMethod(Invoker.java:667) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:840) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1141) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:137) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:121) at org.testng.TestRunner.runWorkers(TestRunner.java:1108) at org.testng.TestRunner.privateRun(TestRunner.java:737) at org.testng.TestRunner.run(TestRunner.java:596) at org.testng.SuiteRunner.runTest(SuiteRunner.java:315) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:310) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:272) at org.testng.SuiteRunner.run(SuiteRunner.java:221) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1028) at org.testng.TestNG.runSuitesLocally(TestNG.java:965) at org.testng.TestNG.run(TestNG.java:896)
I thought two WARs might have posed a problem, but I tried disabling the second WAR package in all POMs (main POM, and ear POM) and removed it from dependencies, but nothing changes.
What are possible reasons of application context not being initialized properly? I'm getting clueless at trying to debug that problem. The project is virtually identical to that of seam-maven-refimpl - it works there, but not here though.
I would appreciate any clues or hints!
Thanks,
M.