Which service would that be? Could you provide a stack trace?

Perhaps you could make your service contribute to RegistryStartup as well,
to make sure the DbShutdownImpl service is realized and that the
sessionSource is realized. The "startupService" would then be the registry
startup method.

I agree that modifying TapestryFilter is an ugly solution and should be
avoided if possible.


On Mon, 29 Nov 2010 21:06:50 +1100, Paul Stanton <p...@mapshed.com.au>
wrote:
> same error, different service which can't be injected.
> 
> On 29/11/2010 8:13 PM, Tom van Dijk wrote:
>> What if you do this:
>>
>> public class DbShutdownImpl implements DbShutdown, 
>> RegistryShutdownListener
>> {
>>     @Inject
>>     private HibernateSessionSource sessionSource;
>>
>>     private final static Logger LOG = 
>> Logger.getLogger(DbShutdownImpl.class);
>>
>>     @PostInjection
>>     public void startupService(RegistryShutdownHub shutdownHub)
>>     {
>>         // make sure session source is real
>>         sessionSource.getSession();
>>         shutdownHub.addRegistryShutdownListener(this);
>>     }
>>
>>     @Override
>>     public void registryDidShutdown()
>>     {
>>         LOG.error("shutdown called");
>>         Session sess = sessionSource.getSession();
>>         Transaction tr = sess.beginTransaction();
>>         sess.createSQLQuery("SHUTDOWN").executeUpdate();
>>         tr.commit();
>>         sess.close();
>>     }
>> }
>>
>>
>>
>>
>>
>> Op 29-11-2010 6:28, Paul Stanton schreef:
>>> 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
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org

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

Reply via email to