This content has been marked as final.
Show 4 replies
-
1. Re: TestNG , EntityHome , No application context active
matt.drees May 31, 2007 2:11 PM (in response to laurence_kirk)I think you'd have to post more code and the stacktrace for people to be able to help.
-
2. Re: TestNG , EntityHome , No application context active
laurence_kirk Jun 3, 2007 3:05 PM (in response to laurence_kirk)this is the test code
The persist does succeed, and I get a row in the db, so I'm assuming its something about TestNG that I havent get set up correctly.@Test public final void testCreate() { EntityManagerFactory emf = Persistence.createEntityManagerFactory("entityManager"); System.out.println("created emf "+ emf); EntityManager em = emf.createEntityManager(); TestEntityHome teh = new TestEntityHome(); teh.setEntityManager(em); em.getTransaction().begin(); TestEntity te = teh.createInstance(); te.setId(12); teh.setInstance(te); teh.getInstance(); teh.persist(); em.getTransaction().commit(); }
TestEntityHome is a sublcass of Entity Home as followspublic class TestEntityHome<E> extends EntityHome { @Override public TestEntity createInstance() { TestEntity te = new TestEntity(); return te; } }
[testng] 20:07:10,359 INFO [SchemaUpdate] schema update complete
[testng] created emf org.hibernate.ejb.EntityManagerFactoryImpl@186d484
[testng] 20:07:10,625 INFO [DriverManagerConnectionProvider] cleaning up connection pool: jdbc:mysql://*********
[testng] 20:07:10,640 INFO [DriverManagerConnectionProvider] cleaning up connection pool: jdbc:mysql://***********
[testng] 20:07:10,843 WARN [AbstractEntityManagerImpl] Calling joinTransaction() on a non JTA EntityManager
[testng] Hibernate: insert into XTEST (name, id) values (?, ?)
[testng] Creating E:\jbossseam\dev\testp1\test-report\Entity Home Test.html
[testng] FAILED: org.jboss.seam.mock.SeamTest.end()
[testng] java.lang.NullPointerException
[testng] at org.jboss.seam.contexts.WebApplicationContext.get(WebApplicationContext.java:48)
[testng] at org.jboss.seam.Component.forName(Component.java:1579)
[testng] at org.jboss.seam.Component.getInstance(Component.java:1627)
[testng] at org.jboss.seam.Component.getInstance(Component.java:1622)
[testng] at org.jboss.seam.Component.getInstance(Component.java:1599)
[testng] at org.jboss.seam.Component.getInstance(Component.java:1594)
[testng] at org.jboss.seam.core.ConversationEntries.instance(ConversationEntries.java:91)
[testng] at org.jboss.seam.contexts.Lifecycle.endSession(Lifecycle.java:284)
[testng] at org.jboss.seam.mock.SeamTest.end(SeamTest.java:676)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[testng] at java.lang.reflect.Method.invoke(Method.java:585)
[testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:529)
[testng] at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:311)
[testng] at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:149)
[testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:467)
[testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:625)
[testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:88)
[testng] at org.testng.TestRunner.privateRun(TestRunner.java:614)
[testng] at org.testng.TestRunner.run(TestRunner.java:505)
[testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
[testng] at org.testng.SuiteRunner.run(SuiteRunner.java:147)
[testng] at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
[testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
[testng] at org.testng.TestNG.run(TestNG.java:316)
[testng] at org.testng.TestNG.privateMain(TestNG.java:666)
[testng] at org.testng.TestNG.main(TestNG.java:608)
[testng] FAILED: test.ActualTestClass.testCreate()
[testng] java.lang.IllegalStateException: No application context active
[testng] at org.jboss.seam.Component.forName(Component.java:1577)
[testng] at org.jboss.seam.Component.getInstance(Component.java:1627)
[testng] at org.jboss.seam.Component.getInstance(Component.java:1622)
[testng] at org.jboss.seam.Component.getInstance(Component.java:1599)
[testng] at org.jboss.seam.Component.getInstance(Component.java:1594)
[testng] at org.jboss.seam.persistence.PersistenceProvider.instance(PersistenceProvider.java:56)
[testng] at org.jboss.seam.framework.EntityHome.persist(EntityHome.java:50)
[testng] at test.ActualTestClass.testCreate(ActualTestClass.java:63)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[testng] at java.lang.reflect.Method.invoke(Method.java:585)
[testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:529)
[testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:398)
[testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:625)
[testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:88)
[testng] at org.testng.TestRunner.privateRun(TestRunner.java:614)
[testng] at org.testng.TestRunner.run(TestRunner.java:505)
[testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
[testng] at org.testng.SuiteRunner.run(SuiteRunner.java:147)
[testng] at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
[testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
[testng] at org.testng.TestNG.run(TestNG.java:316)
[testng] at org.testng.TestNG.privateMain(TestNG.java:666)
[testng] at org.testng.TestNG.main(TestNG.java:608)
[testng] SKIPPED: destroy
[testng] SKIPPED: cleanup
[testng] ===============================================
[testng] Entity Home Test
[testng] Tests run: 4, Failures: 2, Skips: 2
[testng] ===============================================
[testng] Creating E:\jbossseam\dev\testp1\test-report\testng-failed.xml
[testng] ===============================================
[testng] Entity Home
[testng] Total tests run: 4, Failures: 2, Skips: 2
[testng] ===============================================
[testng] Creating E:\jbossseam\dev\testp1\test-report\toc.html
[testng] Creating E:\jbossseam\dev\testp1\test-report\Entity Home Test.properties
[testng] Creating E:\jbossseam\dev\testp1\test-report\index.html
[testng] Creating E:\jbossseam\dev\testp1\test-report\main.html
[testng] Creating E:\jbossseam\dev\testp1\test-report\groups.html
[testng] Creating E:\jbossseam\dev\testp1\test-report\methods.html
[testng] Creating E:\jbossseam\dev\testp1\test-report\classes.html
BUILD SUCCESSFUL
Total time: 21 seco -
3. Re: TestNG , EntityHome , No application context active
nakhnoukh Oct 22, 2007 9:10 PM (in response to laurence_kirk)I'm having the exact same issue. Anyone know how to get around this?
Defeats the point of the unit test if you have to duplicate the CRUD code in the unit test as you're not actually testing the code that runs normally. -
4. Re: TestNG , EntityHome , No application context active
norman.richards Oct 22, 2007 10:07 PM (in response to laurence_kirk)If you need the contexts available, try running this inside of a ComponentTest.