Session expiration problem in Sun ONE Appserver - please help

J

jan

Hi world,

I attempt to perform some cleanup work in the database whenever an
HttpSession expires. In order to do this I declared one of the session
attributes to implement HttpSessionBindingListener and put my cleanup
tasks in the valueUnbound() method. Everything works fine when the
session is invalidated explicitly (via session.invalidate()). However,
when the session expires I get the following stack trace:

[20/Nov/2003:11:39:59] SEVERE (14720): StandardManager[/myApp]
processsExpire: Exception during session expiration
com.sun.enterprise.InvocationException
at
com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.
java:134)
at
com.sun.enterprise.resource.JdbcDataSource.internalGetConnection(JdbcDat
aSource.java:241)
at
com.sun.enterprise.resource.JdbcDataSource.getConnection(JdbcDataSource.
java:98)
at de.glovis.ecom.MyObj.doCleanup(MyObj.java:890)
at de.glovis.ecom.MyObj.valueUnbound(MyObj.java:965)
at
org.apache.catalina.session.StandardSession.removeAttribute(StandardSess
ion.java:1116)
at
org.apache.catalina.session.StandardSession.expire(StandardSession.java:
611)
at
org.apache.catalina.session.StandardManager.processExpires(StandardManag
er.java:755)
at
org.apache.catalina.session.StandardManager.run(StandardManager.java:832)
at java.lang.Thread.run(Thread.java:534)

I must admit that I have no clue what happens here. Is this a bug of the
S1 AppServer? I sincerely hope that the truth is out there...;-)

Thanks in advance for any hints you can give me.
Jan
 
E

Erwin Moller

(e-mail address removed) wrote:

Hi Jan,
Hi world,

I attempt to perform some cleanup work in the database whenever an
HttpSession expires. In order to do this I declared one of the session
attributes to implement HttpSessionBindingListener and put my cleanup
tasks in the valueUnbound() method. Everything works fine when the
session is invalidated explicitly (via session.invalidate()). However,
when the session expires I get the following stack trace:

[20/Nov/2003:11:39:59] SEVERE (14720): StandardManager[/myApp]
processsExpire: Exception during session expiration
com.sun.enterprise.InvocationException
at
com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.
java:134)
at
com.sun.enterprise.resource.JdbcDataSource.internalGetConnection(JdbcDat
aSource.java:241)
at
com.sun.enterprise.resource.JdbcDataSource.getConnection(JdbcDataSource.
java:98)


I have to admit I am not sure either, but by the looks of the complaints my
guess would be that you cannot get a valid connection to your
databaseconnectionpool.
That would be the first thing to investigate.

*Maybe* the session that will be invalidated will loose its ability to gain
access that pool in your situation. ???

Are you somehow using a stale connection?
You are not storing connections in your session-objects, are you?
That would be a mistake (waste of resources)
I ask this because if you DO store you connection per session, that would
explain this situation. Many databases invalidate databaseconnections after
a certain period of idle-time.

Hmm, as you can see I am not sure either.

Good luck and keep us informed.
Regards,
Erwin Moller
 
J

jan

Hi Erwin,

Sorry, it's not that easy ;-) I do not store any connections at all,
neither in sessions nor anywhere else. Instead, I use a ConnectionPool
provided by the appserver and store the corresponding DataSource in the
ServletContext, i.e. at application scope, so it should definitely remain
accessible even when a particular session times out.
Thanks for your hints anyway...;-)

Kind regards,
Jan


Am 11/20/03, 2:02:45 PM, schrieb Erwin Moller
<[email protected]> zum Thema
Re: Session expiration problem in Sun ONE Appserver - please help:

(e-mail address removed) wrote:
Hi Jan,
Hi world,

I attempt to perform some cleanup work in the database whenever an
HttpSession expires. In order to do this I declared one of the session
attributes to implement HttpSessionBindingListener and put my cleanup
tasks in the valueUnbound() method. Everything works fine when the
session is invalidated explicitly (via session.invalidate()). However,
when the session expires I get the following stack trace:

[20/Nov/2003:11:39:59] SEVERE (14720): StandardManager[/myApp]
processsExpire: Exception during session expiration
com.sun.enterprise.InvocationException
at
com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.
java:134)
at
com.sun.enterprise.resource.JdbcDataSource.internalGetConnection(JdbcDat
aSource.java:241)
at
com.sun.enterprise.resource.JdbcDataSource.getConnection(JdbcDataSource.
java:98)

I have to admit I am not sure either, but by the looks of the complaints my
guess would be that you cannot get a valid connection to your
databaseconnectionpool.
That would be the first thing to investigate.
*Maybe* the session that will be invalidated will loose its ability to gain
access that pool in your situation. ???
Are you somehow using a stale connection?
You are not storing connections in your session-objects, are you?
That would be a mistake (waste of resources)
I ask this because if you DO store you connection per session, that would
explain this situation. Many databases invalidate databaseconnections after
a certain period of idle-time.
 
S

Sudsy

Hi world,

I attempt to perform some cleanup work in the database whenever an
HttpSession expires. In order to do this I declared one of the session
attributes to implement HttpSessionBindingListener and put my cleanup
tasks in the valueUnbound() method. Everything works fine when the
session is invalidated explicitly (via session.invalidate()). However,
when the session expires I get the following stack trace:
I must admit that I have no clue what happens here. Is this a bug of the
S1 AppServer? I sincerely hope that the truth is out there...;-)

Thanks in advance for any hints you can give me.
Jan

Without seeing the code, my question would be how you obtain
a Connection when in the clean-up code. You're not going to
be operating within the context of HttpServlet#service so
you'd have to maintain appropriate references in your class
which implements HttpSessionBindingListener.
Just off the top of my head, of course. YMMV.
 
J

jan

I use a ConnectionPool provided by the appserver and store the
corresponding DataSource in the ServletContext, i.e. at application
scope, so it should definitely remain accessible even when a particular
session times out.

Am 11/20/03, 4:41:08 PM, schrieb Sudsy <[email protected]> zum Thema
Re: Session expiration problem in Sun ONE Appserver - please help:
 
S

Sudsy

I use a ConnectionPool provided by the appserver and store the
corresponding DataSource in the ServletContext, i.e. at application
scope, so it should definitely remain accessible even when a particular
session times out.

So you've got something like this?

<in servlet>

// req is the HttpServletRequest

DataSource ds = (DataSource) getServletContext().getAttribute(
"your_data_source" );
req.getSession().setAttribute( "your_attribute_name",
new ListenerObject( ds ) );

<in ListenerObject>

public class ListenerObject implements HttpSessionBindingListener {

DataSource ds;

public ListenerObject( DataSource ds ) {
this.ds = ds;
}

public void valueUnbound( HttpSessionBindingEvent evt ) {
Connection conn = null;
try {
conn = ds.getConnection();
...
}
catch( ... ) {
...
}
}
}
 
J

jan

Not exactly but yes, something like that. Works perfectly when a
session.invalidate() is done, only breaks when the session times out :(


Am 11/20/03, 9:06:07 PM, schrieb Sudsy <[email protected]> zum Thema
Re: Session expiration problem in Sun ONE Appserver - please help:

So you've got something like this?
<in servlet>
// req is the HttpServletRequest
DataSource ds = (DataSource) getServletContext().getAttribute(
"your_data_source" );
req.getSession().setAttribute( "your_attribute_name",
new ListenerObject( ds ) );
<in ListenerObject>
public class ListenerObject implements HttpSessionBindingListener {
DataSource ds;
 
S

Sudsy

Not exactly but yes, something like that. Works perfectly when a
session.invalidate() is done, only breaks when the session times out :(

So you're not trying to pull anything out of the session
(credentials, etc.) when trying to establish the connection?
It doesn't help that even a search on the Sun site doesn't
find any matches for the exception you're reporting...
You might have to go straight to the vendor on this one.
 
J

jan

Well, I guess I'll have to do that. I also tried to find this exception
somewhere on the Net - no results. Thanks for your help anyway...

Am 11/21/03, 6:39:28 AM, schrieb Sudsy <[email protected]> zum Thema
Re: Session expiration problem in Sun ONE Appserver - please help:
 
E

Erwin Moller

Jan, please post the solution, if you find it, here.
So the next Jan with this problem has more luch than you do.
;-)

Good luck and have a nice weekend (if possible after such an error).

Regards,
Erwin Moller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top