Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354080 - ServletContextHandler doesn't work when added after server is started, unless created with Session handler
Summary: ServletContextHandler doesn't work when added after server is started, unless...
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: 7.4.5   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 7.5.x   Edit
Assignee: Michael Gorovoy CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-07 00:23 EDT by Mark A. Ziesemer CLA
Modified: 2011-08-24 19:12 EDT (History)
3 users (show)

See Also:


Attachments
Minimal test case. (1.55 KB, text/x-java)
2011-08-07 00:23 EDT, Mark A. Ziesemer CLA
no flags Details
Log file from test case. (10.85 KB, text/plain)
2011-08-07 00:24 EDT, Mark A. Ziesemer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark A. Ziesemer CLA 2011-08-07 00:23:07 EDT
Created attachment 201040 [details]
Minimal test case.

I'm using Jetty embedded for running JUnit tests against a servlet.  I was trying to upgrade from 7.1.2 to 7.4.5, but something broke (or at least changed) between 7.1.3 and 7.1.4.  For performance of running many tests rounds, I was programatically stopping the ServletContextHandler (a WebAppContext), calling .setServletHandler() on it with a new ServletHolder, then restarting the ServletContextHandler.  This was working great with older versions since at least the early 6.x series, but after upgrading to 7.1.4 or above, Jetty only responds with a HTTP 404 for what should be valid requests.

There is very little documentation that I can find around use of this class.  However, after finding an example at http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty that passed ServletContextHandler.SESSIONS to the ServletContextHandler constructor, I did the same - and it worked.

I reviewed the change log for 7.1.4, and could not see anything to explain this.  I also reviewed the source code for ServletContextHandler between 7.1.3 and 7.1.4, and while there is one difference, I can't see how it would be relevant - so the change affecting this must be elsewhere in the code.

I've attached a minimal test case.  On versions of Jetty 7.1.3 and below, it will output "200" for HTTP OK.  On versions 7.1.4 and above, it will output "404" for HTTP Not Found.  After uncommenting the ServletContextHandler.SESSIONS flag, it will again output "200" for versions 7.1.4 and above - but this test should not require any HTTP session support.

Even running with all logging enabled, there are no errors, warnings, or anything else present to help indicate what is happening here.  I will attach the log file that was generated from the same minimal test case.
Comment 1 Mark A. Ziesemer CLA 2011-08-07 00:24:41 EDT
Created attachment 201041 [details]
Log file from test case.
Comment 2 Michael Gorovoy CLA 2011-08-24 19:12:07 EDT
The change that made it impossible to replace ServletHandler, SessionHandler, and SecurityHandler in certain circumstances was intended to allow setting additional HandlerWrapper(s) on a ServletContextHandler object. This can be used for example to allow configuring a context specific request log file.

The fix for this issue along with a test harness has been pushed to master for final Jetty 7.5.0 release.