JavaTomcatNewbie
Programmer
Win 2000
Jakarta Tomcat 4.0.3
JDK 1.3
I'm getting an exception in Tomcat 4.0.3 that I don't know what to do with. I'm reading James Goodwill's book "Apache Jakarta-Tomcat" and I'm trying to run the example
On page page 128. I'm using Mysql and session data shows up in the database some of the time, other times Tomcat throws the exception. It seems like Tomcat checks the database every 60 seconds to see which sessions have timed out and everytime it throws the exception. I'm new to this, sorry for posting all the code, but I have been working on this for 3 days. I'm new to mysql also.
The books says that Tomcat will manage sessions in a database for you. I see the data in the database but then.. I get this and all of the session information isn't in the database.
Tim
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.ibjectInputStream.readFullyInternal(ObjectInputStream.java:1780)
at java.ibjectInputStream.bufferData(ObjectInputStream.java:1750)
at java.ibjectInputStream.readShort(ObjectInputStream.java:1935)
at java.ibjectInputStream.readStreamHeader(ObjectInputStream.java:842)
at java.ibjectInputStream.<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>
The servlet is straight from the book and it looks like this....
package chapter7;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html"
PrintWriter out = response.getWriter();
out.println("<html>"
out.println("<body bgcolor=\"white\">"
out.println("<head>"
out.println("<title>Session Servlet</title>"
out.println("</head>"
out.println("<body>"
// Get a reference to the HttpSession Object
HttpSession session = request.getSession();
// Print the current Session's ID
out.println("Session ID:" + " " + session.getId());
out.println("<br>"
// Print the current Session's Creation Time
out.println("Session Created:" + " " +
new Date(session.getCreationTime()) + "<br>"
// Print the current Session's Last Access Time
out.println("Session Last Accessed" + " " +
new Date(session.getLastAccessedTime()));
// Get the name/value pair to be placed in the HttpSession
String dataName = request.getParameter("name"
String dataValue = request.getParameter("value"
if ( dataName != null && dataValue != null ) {
// If the Parameter Values are not null
// then add the name/value pair to the HttpSession
session.setAttribute(dataName, dataValue);
}
out.println("<P>"
out.println("Sessions Attributes" + "<br>"
// Get all of the Attribute Names from the HttpSession
Enumeration names = session.getAttributeNames();
while ( names.hasMoreElements() ) {
String name = (String) names.nextElement();
// Get the Attribute Value with the matching name
String value = session.getAttribute(name).toString();
// Print the name/value pair
out.println(name + " = " + value + "<br>"
}
// Create a Form to Add name/value pairs to the HttpSession
out.println("<P>GET based form:<br>"
out.print("<form action=\""
out.print(response.encodeURL("chapter7.SessionServlet");
out.print("\" "
out.println("method=GET>"
out.println("Session Attribute:"
out.println("<input type=text size=20 name=name>"
out.println("<br>"
out.println("Session Value:"
out.println("<input type=text size=20 name=value>"
out.println("<br>"
out.println("<input type=submit>"
out.println("</form>"
out.println("</body>"
out.println("</html>"
}
}
Jakarta Tomcat 4.0.3
JDK 1.3
I'm getting an exception in Tomcat 4.0.3 that I don't know what to do with. I'm reading James Goodwill's book "Apache Jakarta-Tomcat" and I'm trying to run the example
On page page 128. I'm using Mysql and session data shows up in the database some of the time, other times Tomcat throws the exception. It seems like Tomcat checks the database every 60 seconds to see which sessions have timed out and everytime it throws the exception. I'm new to this, sorry for posting all the code, but I have been working on this for 3 days. I'm new to mysql also.
The books says that Tomcat will manage sessions in a database for you. I see the data in the database but then.. I get this and all of the session information isn't in the database.
Tim
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.ibjectInputStream.readFullyInternal(ObjectInputStream.java:1780)
at java.ibjectInputStream.bufferData(ObjectInputStream.java:1750)
at java.ibjectInputStream.readShort(ObjectInputStream.java:1935)
at java.ibjectInputStream.readStreamHeader(ObjectInputStream.java:842)
at java.ibjectInputStream.<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>
The servlet is straight from the book and it looks like this....
package chapter7;
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SessionServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html"
PrintWriter out = response.getWriter();
out.println("<html>"
out.println("<body bgcolor=\"white\">"
out.println("<head>"
out.println("<title>Session Servlet</title>"
out.println("</head>"
out.println("<body>"
// Get a reference to the HttpSession Object
HttpSession session = request.getSession();
// Print the current Session's ID
out.println("Session ID:" + " " + session.getId());
out.println("<br>"
// Print the current Session's Creation Time
out.println("Session Created:" + " " +
new Date(session.getCreationTime()) + "<br>"
// Print the current Session's Last Access Time
out.println("Session Last Accessed" + " " +
new Date(session.getLastAccessedTime()));
// Get the name/value pair to be placed in the HttpSession
String dataName = request.getParameter("name"
String dataValue = request.getParameter("value"
if ( dataName != null && dataValue != null ) {
// If the Parameter Values are not null
// then add the name/value pair to the HttpSession
session.setAttribute(dataName, dataValue);
}
out.println("<P>"
out.println("Sessions Attributes" + "<br>"
// Get all of the Attribute Names from the HttpSession
Enumeration names = session.getAttributeNames();
while ( names.hasMoreElements() ) {
String name = (String) names.nextElement();
// Get the Attribute Value with the matching name
String value = session.getAttribute(name).toString();
// Print the name/value pair
out.println(name + " = " + value + "<br>"
}
// Create a Form to Add name/value pairs to the HttpSession
out.println("<P>GET based form:<br>"
out.print("<form action=\""
out.print(response.encodeURL("chapter7.SessionServlet");
out.print("\" "
out.println("method=GET>"
out.println("Session Attribute:"
out.println("<input type=text size=20 name=name>"
out.println("<br>"
out.println("Session Value:"
out.println("<input type=text size=20 name=value>"
out.println("<br>"
out.println("<input type=submit>"
out.println("</form>"
out.println("</body>"
out.println("</html>"
}
}