Hi, After using Jboss 2.4 + Tomcat for a long time I wanted to see if my project runs fine with Jboss 3.0 and default web container (Jetty). I'm now getting an exception from the web container. I'm not sure if I did something wrong what was tolerated by tomcat so far or if it's a bug.
In some circumstances my servlet has to invalidate the current session
and create a new one. This is done as shown in the following
Test-Servlet:
---- 8< ----------------------------------
package de.alxs.jboss;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
*
*
* @author $Author$
* @version $Revision$ ($Date$)
*/
public class SessionTest extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response) {
HttpSession session = request.getSession();
session.setAttribute("blubber", "preinvalidate");
session.invalidate();
session = request.getSession(true);
// Exception is thrown here
session.setAttribute("blubber", "Blubberarg");
try {
ServletOutputStream out = response.getOutputStream();
out.println("<html><body>OK!</body></html>");
} catch (IOException e) {
}
}
public void doPost(HttpServletRequest request, HttpServletResponse
response) {
doGet(request, response);
}
}
---- 8< ----------------------------------
When accessing this servlet the first time I get the following
exception:
17:04:43,788 WARN [jbossweb] WARNING: Exception for
/jb_test/test/session
java.lang.IllegalStateException
at
org.mortbay.jetty.servlet.AbstractSessionManager$Session.setAttribute(Ab
stractSessionManager.java:550)
at de.alxs.jboss.SessionTest.doGet(SessionTest.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:366)
at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationH
andler.java:284)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:577)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1674)
at
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationCon
text.java:544)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1624)
at org.mortbay.http.HttpServer.service(HttpServer.java:875)
at org.jboss.jetty.Jetty.service(Jetty.java:541)
at
org.mortbay.http.HttpConnection.service(HttpConnection.java:785)
at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:935)
at
org.mortbay.http.HttpConnection.handle(HttpConnection.java:802)
at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:200
)
at
org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:294)
at
org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:743)
at java.lang.Thread.run(Thread.java:536)
After that I'm able to rerun the servlet without any problems as long as
I don't close and restart the browser.
I've added the war for testing. The URL is
http://localhost:8080/jb_test/test/session
Thanks!
Alexander Sparkowsky, Berlin, Germany
jb_test.war
Description: Binary data
