You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Wechsung, Wulf" <wu...@sap.com> on 2014/04/28 14:13:22 UTC

Problem with reinitializing a registry

Hello T5-Users,



I'm very much stuck on this issue and hoping someone here can maybe help me.

So our project does extensive Unit Tests with Page Tester and essentially all services substituted or mocked out (for example in-memory database). We've had a few issues with test stability as we used a singleton registry that was initialized at the beginning of all tests and reused for each test case. To increase reliability (at the cost of execution time) I want to start and shutdown the registry for each test class. Unfortunately I get this error on the second test class:



Caused by: java.lang.RuntimeException: Exception constructing service 'NestedTransactionSessionManager': Proxy for service NestedTransactionSessionManager is no longer active because the IOC Registry has been shut down.

       at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:75)



This service is used as a service override for HibernateSessionManager.



This is in our common test super class:



    @AfterClass(alwaysRun = true)

    public void tearDownBaseSatellitePageTesterTests() {

        if (registry != null) {

            logger.error("Shutting down registry afterClass");

            registry.cleanupThread();

            registry.shutdown();

        }



    }



By the logging I can see that this ran but still the above error persists. How is this possible? The location of the error is actually in a @Startup method of one of the modules initialized:



Caused by: org.apache.tapestry5.ioc.internal.OperationException: Error invoking service contribution method com.crossgate.maelstrom.satellite.services.SatelliteModule.updateDatabase(Logger, boolean, DatabaseMigration, DBConnPool, HibernateSessionSource, TransactionStateDaoService, NavigationService, RootUserCreateService, TransRuleDao, String):



This is the declaration of that method:



    @Startup

    public static void updateDatabase(

            final Logger logger,

            @Symbol(MaelstromSchemaSymbols.AUTOBASE) final boolean autobase,

            @Inject final DatabaseMigration databaseMigration,

            @Inject final DBConnPool dbConnPool,

            @Inject final HibernateSessionSource sessionSource,

            @Inject final TransactionStateDaoService taStateDaoService,

            @Inject final NavigationService navigationService,

            @Inject final RootUserCreateService rucs,

            @Inject final TransRuleDao transRuleDao,

            @Inject @Symbol(SymbolConstants.APPLICATION_VERSION) final String satelliteVersion

            ) throws LiquibaseException, SQLException, Exception {







This is the code I use to initialize the registry in @BeforeClass of the same common test super class (EmbeddedPageTester is a sub-class of PageTester but has no static fields):



       EmbeddedPageTester instance = new EmbeddedPageTester("com.crossgate.maelstrom.satellite", "SatelliteZ",

                "src/main/webapp",

                SatelliteTestModule.class);

        return instance;





We use TESTNG to run our test.



Any pointers would be greatly appreciated!



Thanks in advance and kind regards,

Wulf