File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes JDBC Realms and Session Tracking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "JDBC Realms and Session Tracking" Watch "JDBC Realms and Session Tracking" New topic
Author

JDBC Realms and Session Tracking

Tim Kelley
Greenhorn

Joined: Jul 16, 2002
Posts: 8
I bought the book Apache-Jakarta-Tomcat.
It has an example of session tracking with a database. I installed mysql but I'm having problems. Its seems like the first couple of session data get put in the database. Then after 60 seconds, I think tomcat checks the database to see if any sessions have expired. Thats when I get the error in Tomcat. I listed the server.xml portion of code after the exception. Please help!!!
The exception I'm getting is
java.io.IOException: Stream closed
at java.io.BufferedInputStream.ensureOpen(BufferedInputStream.java:123)
at java.io.BufferedInputStream.read(BufferedInputStream.java:273)
at java.io.ObjectInputStream.readFullyInternal(ObjectInputStream.java:1780)
at java.io.ObjectInputStream.bufferData(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readShort(ObjectInputStream.java:1935)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:842)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:168)
at org.apache.catalina.util.CustomObjectInputStream.<init>(CustomObjectInputStream.java:103)
at org.apache.catalina.session.JDBCStore.load(JDBCStore.java:518)
at org.apache.catalina.session.StoreBase.processExpires(StoreBase.java:295)
at org.apache.catalina.session.StoreBase.run(StoreBase.java:350)
at java.lang.Thread.run(Thread.java:484)
The relative portion of the server.xml file is...
<Context path="/library2" docBase="library2" debug="0" reloadable="true">
<Manager className="org.apache.catalina.session.PersistentManager"
debug="0"
saveOnRestart="true"
maxActiveSessions="-1"
minIdleSwap="-1"
maxIdleSwap="-1"
maxIdleBackup="-1">
<Store className="org.apache.catalina.session.JDBCStore"
driverName="org.gjt.mm.mysql.Driver"
connectionURL="jdbc:mysql://localhost/tomcatsessions?user=SessionTracking;password=tracking"
sessionTable="sessions"
sessionIdCol="id"
sessionDataCol="data"
sessionValidCol="valid"
sessionMaxInactiveCol="maxinactive"
sessionLastAccessedCol="lastaccess"
checkInterval="60"
debug="99" />

</Manager>


</Context>
Tim Kelley
Greenhorn

Joined: Jul 16, 2002
Posts: 8
I was able to get rid of the errors by taking the authentication script in the web.xml file for the same servlet. If the servlet has basic authentication using a JDBC Realm then I get the exception stated in the first post.
I changed the settings of my sessions to time out at 10 seconds and limited the number of sessions that can be in the database at a time and I never saw a 10 second session dissapear from the session database.
Does the Tomcat JDBCStore stuff work??
Has anyone else used it with good results?
Tim
[ July 17, 2002: Message edited by: Tim Kelley ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC Realms and Session Tracking
 
Similar Threads
Tomcat Access Problem
Security Contraints setup..
local_host error-HELP
HttpSession ... tracking and cleanup
tomcat web application folder setting