tags:

views:

198

answers:

0

Hi, I have this simple class:

    public class LuceneUtil{

    private final EntityManager entityManager;

public LuceneUtil() {
        entityManager = (EntityManager) Component.getInstance("entityManager");
    }

//other code
}

If i use this class "normally" (i mean with deploy and etc) all works well. But, if i try to use it from my test classes, when it tries to load the entityManager, it gives:

java.lang.IllegalStateException: No application context active

Does anyone has any ideea: why?

Stacktrace:

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 com.unifiedpost.my.docstore.query.LucenePropertyUtil.<init>(LucenePropertyUtil.java:27)
    at com.unifiedpost.my.docstore.query.PropertyQuery.<init>(PropertyQuery.java:16)
    at com.unifiedpost.my.docstore.query.EqualsPropertyQuery.<init>(EqualsPropertyQuery.java:16)
    at com.unifiedpost.docstore.it.rest.queries.QueryBuilder.prepareEquals(QueryBuilder.java:21)
    at com.unifiedpost.docstore.it.DocumentImporterTest.reindex(DocumentImporterTest.java:134)
    at com.unifiedpost.docstore.it.DocumentImporterTest.importDocumentAndIndexIt(DocumentImporterTest.java:107)
    at com.unifiedpost.docstore.it.rest.queries.InboxIndexQueryResourceBeanTest.testPropertyQuery(InboxIndexQueryResourceBeanTest.java:37)
    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:580)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:517)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:669)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:956)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
    at org.testng.TestRunner.runWorkers(TestRunner.java:720)
    at org.testng.TestRunner.privateRun(TestRunner.java:590)
    at org.testng.TestRunner.run(TestRunner.java:484)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:332)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:327)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299)
    at org.testng.SuiteRunner.run(SuiteRunner.java:204)
    at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:864)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:830)
    at org.testng.TestNG.run(TestNG.java:748)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
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 com.unifiedpost.my.docstore.query.LucenePropertyUtil.<init>(LucenePropertyUtil.java:27)
    at com.unifiedpost.my.docstore.query.PropertyQuery.<init>(PropertyQuery.java:16)
    at com.unifiedpost.my.docstore.query.EqualsPropertyQuery.<init>(EqualsPropertyQuery.java:16)
    at com.unifiedpost.docstore.it.rest.queries.QueryBuilder.prepareEquals(QueryBuilder.java:21)
    at com.unifiedpost.docstore.it.DocumentImporterTest.reindex(DocumentImporterTest.java:134)
    at com.unifiedpost.docstore.it.DocumentImporterTest.importDocumentAndIndexIt(DocumentImporterTest.java:107)
    at com.unifiedpost.docstore.it.rest.queries.InboxIndexQueryResourceBeanTest.testPropertyQuery(InboxIndexQueryResourceBeanTest.java:37)
    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:580)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:517)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:669)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:956)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
    at org.testng.TestRunner.runWorkers(TestRunner.java:720)
    at org.testng.TestRunner.privateRun(TestRunner.java:590)
    at org.testng.TestRunner.run(TestRunner.java:484)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:332)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:327)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299)
    at org.testng.SuiteRunner.run(SuiteRunner.java:204)
    at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:864)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:830)
    at org.testng.TestNG.run(TestNG.java:748)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)