Hi all,

I'm using tapestry-hibernate and an embedded HSQLDB database.

As you might know, it's important to tell HSQLDB to shutdown when you are terminating the vm.

You do this by executing a proprietary SQL query "SHUTDOWN" before closing your last connection.

Ideally I'd like to use hibernate to execute the SQL query since it is already configured to connect to the database.

Currently I am trying to do it like so:

public class DbShutdownImpl implements DbShutdown, RegistryShutdownListener
{
    @Inject
    private Session session;

private final static Logger LOG = Logger.getLogger(DbShutdownImpl.class);

    @PostInjection
    public void startupService(RegistryShutdownHub shutdownHub)
    {
        shutdownHub.addRegistryShutdownListener(this);
    }

    @Override
    @CommitAfter
    public void registryDidShutdown()
    {
        LOG.error("shutdown called");
        session.createSQLQuery("SHUTDOWN").executeUpdate();
    }
}

However, I am getting the exception:

java.lang.RuntimeException: Exception constructing service 'Session': Proxy for service Session is no longer active because the IOC Registry has been shut down. at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:78) at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:57)
    at $Session_12c96175d35.delegate($Session_12c96175d35.java)
    at $Session_12c96175d35.createSQLQuery($Session_12c96175d35.java)
    at mypackage.DbShutdownImpl.registryDidShutdown(DbShutdownImpl.java:29)
at org.apache.tapestry5.ioc.internal.services.RegistryShutdownHubImpl.fireRegistryDidShutdown(RegistryShutdownHubImpl.java:57) at org.apache.tapestry5.ioc.internal.RegistryImpl.shutdown(RegistryImpl.java:411) at org.apache.tapestry5.ioc.internal.RegistryWrapper.shutdown(RegistryWrapper.java:41)
    at org.apache.tapestry5.TapestryFilter.destroy(TapestryFilter.java:169)

I understand that the registry is shutting down and therefore won't handle new requests for managed services.

How do I get around this problem without creating my own JDBC connection in my shutdown handler?

Regards, p.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to