You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Glen Stampoultzis <gs...@iinet.net.au> on 2004/01/19 02:20:17 UTC
How to reload gracefully
I haven't been getting many hits on my questions lately but I'll try anyway.
I have reloading turned on in tapestry. I'm using HSQLDB which opens up
the database in-place.
Currently when the webapp reloads I get an error because HSQLDB is still
holding the database open. What I want to know is how to detect the
tapestry servlet is being reloaded and close the database safely.
Regards,
Glen Stampoultzis
gstamp@iinet.net.au
http://members.iinet.net.au/~gstamp/glen/
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to reload gracefully
Posted by Geoff Longman <gl...@intelligentworks.com>.
If you are talking about
org.apache.tapestry.disable-caching=true
The servlet is not being reloaded per se, the engine is clearing its cached
objects.
here's the code that's invoked...
in AbstractEngine:
public void clearCachedData()
{
_pool.clear();
_pageSource.reset();
_specificationSource.reset();
_templateSource.reset();
_scriptSource.reset();
_stringsSource.reset();
_enhancer.reset();
}
depending on where your holding your connection you could subclass Base
engine and add your own cleanup code by overriding that method. (Just
remomeber to call the super impl!).
Geoff
----- Original Message -----
From: "Glen Stampoultzis" <gs...@iinet.net.au>
To: <ta...@jakarta.apache.org>
Sent: Sunday, January 18, 2004 8:20 PM
Subject: How to reload gracefully
>
> I haven't been getting many hits on my questions lately but I'll try
anyway.
>
> I have reloading turned on in tapestry. I'm using HSQLDB which opens up
> the database in-place.
>
> Currently when the webapp reloads I get an error because HSQLDB is still
> holding the database open. What I want to know is how to detect the
> tapestry servlet is being reloaded and close the database safely.
>
> Regards,
>
>
> Glen Stampoultzis
> gstamp@iinet.net.au
> http://members.iinet.net.au/~gstamp/glen/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: How to reload gracefully
Posted by Glen Stampoultzis <gs...@iinet.net.au>.
At 02:38 PM 19/01/2004, you wrote:
>Sounds like a problem with your database connection pool.
It's not connection pools as such (I think). It's because I'm running the
database in embedded mode. What it does it open exclusive locks on the
database. What I need is someway to tell when the container is reloading
so I can tell the database to close.
>You might want to subclass ApplicationServlet to hook it's init() method,
>and create the connection
>pool there.
>
>Alternately, you could subclass BaseEngine, make it a
>HttpSessionBindingListener and figure out when
>the session ends (or user logs out).
>
>With servlet Api 2.3+, you have more events ... you can create objects
>that live in the
>ServletContext as attributes ... store the connection pool there and get a
>notification as the old
>version of the app shuts down to clean it up and close it out.
Thanks Howard. I might give the servlet spec a good going over and see if
there's any recommended behavior for this situation.
Regards,
Glen
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: where to create database connections?
Posted by Harish Krishnaswamy <hk...@comcast.net>.
I tend to stay away from the core framework classes as much as possible.
I prefer to use the hooks provided, Global and application extensions
are a couple of those. But if you need to be informed of the servlet
lifecycle events, you may have to extend the engine or servlet as
suggested below. If you are looking for plain JDBC connections, a
connection pool bound to JNDI is probably the best bet. Couple options:
DBCP, C3P0.
-Harish
David Moran wrote:
>I found the post below in the archive and the following in the user
>guide. So are there any guidelines as to when to create database
>connections using the global object verses subclassing the
>ApplicationServlet?
>
>The most typical use of the Global object is to interface to J2EE
>resources such as EJB home and remote interfaces or JDBC data sources.
>The shared Global object can cache home and remote interfaces that are
>efficiently shared by all engine instances.
>
>On Sun, 2004-01-18 at 22:38, Howard M. Lewis Ship wrote:
>
>
>>Sounds like a problem with your database connection pool.
>>
>>You might want to subclass ApplicationServlet to hook it's init() method, and create the connection
>>pool there.
>>
>>Alternately, you could subclass BaseEngine, make it a HttpSessionBindingListener and figure out when
>>the session ends (or user logs out).
>>
>>With servlet Api 2.3+, you have more events ... you can create objects that live in the
>>ServletContext as attributes ... store the connection pool there and get a notification as the old
>>version of the app shuts down to clean it up and close it out.
>>
>>--
>>Howard M. Lewis Ship
>>Independent J2EE / Open-Source Java Consultant
>>Creator, Tapestry: Java Web Components
>>http://jakarta.apache.org/tapestry/
>>http://javatapestry.blogspot.com
>>
>>
>>
>>>-----Original Message-----
>>>From: Glen Stampoultzis [mailto:gstamp@iinet.net.au]
>>>Sent: Sunday, January 18, 2004 8:20 PM
>>>To: tapestry-user@jakarta.apache.org
>>>Subject: How to reload gracefully
>>>
>>>
>>>
>>>I haven't been getting many hits on my questions lately but
>>>I'll try anyway.
>>>
>>>I have reloading turned on in tapestry. I'm using HSQLDB
>>>which opens up
>>>the database in-place.
>>>
>>>Currently when the webapp reloads I get an error because
>>>HSQLDB is still
>>>holding the database open. What I want to know is how to detect the
>>>tapestry servlet is being reloaded and close the database safely.
>>>
>>>Regards,
>>>
>>>
>>>Glen Stampoultzis
>>>gstamp@iinet.net.au
>>>http://members.iinet.net.au/~gstamp/glen/
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
where to create database connections?
Posted by David Moran <dm...@nc.rr.com>.
I found the post below in the archive and the following in the user
guide. So are there any guidelines as to when to create database
connections using the global object verses subclassing the
ApplicationServlet?
The most typical use of the Global object is to interface to J2EE
resources such as EJB home and remote interfaces or JDBC data sources.
The shared Global object can cache home and remote interfaces that are
efficiently shared by all engine instances.
On Sun, 2004-01-18 at 22:38, Howard M. Lewis Ship wrote:
> Sounds like a problem with your database connection pool.
>
> You might want to subclass ApplicationServlet to hook it's init() method, and create the connection
> pool there.
>
> Alternately, you could subclass BaseEngine, make it a HttpSessionBindingListener and figure out when
> the session ends (or user logs out).
>
> With servlet Api 2.3+, you have more events ... you can create objects that live in the
> ServletContext as attributes ... store the connection pool there and get a notification as the old
> version of the app shuts down to clean it up and close it out.
>
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Tapestry: Java Web Components
> http://jakarta.apache.org/tapestry/
> http://javatapestry.blogspot.com
>
> > -----Original Message-----
> > From: Glen Stampoultzis [mailto:gstamp@iinet.net.au]
> > Sent: Sunday, January 18, 2004 8:20 PM
> > To: tapestry-user@jakarta.apache.org
> > Subject: How to reload gracefully
> >
> >
> >
> > I haven't been getting many hits on my questions lately but
> > I'll try anyway.
> >
> > I have reloading turned on in tapestry. I'm using HSQLDB
> > which opens up
> > the database in-place.
> >
> > Currently when the webapp reloads I get an error because
> > HSQLDB is still
> > holding the database open. What I want to know is how to detect the
> > tapestry servlet is being reloaded and close the database safely.
> >
> > Regards,
> >
> >
> > Glen Stampoultzis
> > gstamp@iinet.net.au
> > http://members.iinet.net.au/~gstamp/glen/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: How to reload gracefully
Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
Sounds like a problem with your database connection pool.
You might want to subclass ApplicationServlet to hook it's init() method, and create the connection
pool there.
Alternately, you could subclass BaseEngine, make it a HttpSessionBindingListener and figure out when
the session ends (or user logs out).
With servlet Api 2.3+, you have more events ... you can create objects that live in the
ServletContext as attributes ... store the connection pool there and get a notification as the old
version of the app shuts down to clean it up and close it out.
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry/
http://javatapestry.blogspot.com
> -----Original Message-----
> From: Glen Stampoultzis [mailto:gstamp@iinet.net.au]
> Sent: Sunday, January 18, 2004 8:20 PM
> To: tapestry-user@jakarta.apache.org
> Subject: How to reload gracefully
>
>
>
> I haven't been getting many hits on my questions lately but
> I'll try anyway.
>
> I have reloading turned on in tapestry. I'm using HSQLDB
> which opens up
> the database in-place.
>
> Currently when the webapp reloads I get an error because
> HSQLDB is still
> holding the database open. What I want to know is how to detect the
> tapestry servlet is being reloaded and close the database safely.
>
> Regards,
>
>
> Glen Stampoultzis
> gstamp@iinet.net.au
> http://members.iinet.net.au/~gstamp/glen/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org