Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341643

Summary: HttpService does not work on Servlet 3.0
Product: [Eclipse Project] Equinox Reporter: Thomas Watson <tjwatson>
Component: CompendiumAssignee: Simon Archer <sja.eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, gunnar, hmalphettes, john.arthorne, rgrunber, rsternberg, ruediger.herrmann, simon_kaegi, sja.eclipse, yxzhong
Version: 3.7   
Target Milestone: Juno M3   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Bug Depends on:    
Bug Blocks: 309529, 346446, 355565    

Description Thomas Watson CLA 2011-04-01 11:39:39 EDT
The org.eclipse.equinox.http.servlet bundle provides a base for implementing the  OSGi HttpService.  This base bundle currently will not work for 3.0 servlet containers.  This is most problematic when using the servlet bridge on a server that supports servlet 3.0.

The main issue here is that the ServletContext has new methods and new return types added in servlet 3.0.  We will have to implement the new methods and return the new types for servlet 3.0.  This will be problematic for us because we still want to run on servlet 2.x as well.  The current thought is we can put the new servlet 3.0 types on our private class path for build purposes only and add the new methods for servlet 3.0.  We would not ship the new types and all the new methods would likely throw unsupported exceptions.
Comment 1 Thomas Watson CLA 2011-07-19 16:41:12 EDT
The suggestion to use the same org.eclipse.equinox.http.servlet bundle to support both 2.x and 3.0 may prove to be a build nightmare.  We may want to consider create a branch that contains the support for 2.x and use master to support 3.0 servlet.  Then we would have to consider the need to build both versions during the equinox build.
Comment 2 Thomas Watson CLA 2011-07-19 16:42:09 EDT
I think we need to investigate this for Juno.  We likely should also investigate running with Jetty 8 to test this.
Comment 3 Thomas Watson CLA 2011-09-07 15:30:58 EDT
also see bug309529
Comment 4 Simon Archer CLA 2011-09-20 15:46:15 EDT
I have created a github repository into which I have cloned the Equinox Git repository rt.equinox.bundles.git:

remote.origin.url=https://simonjarcher@github.com/simonjarcher/rt.equinox.bundles.git

I have just committed my initial changes to the above repository. These changes are still a work-in-progress and are currently being tested.  The only project I've changed is org.eclipse.equinox.http.servlet.
Comment 5 Hugues Malphettes CLA 2011-10-14 23:34:45 EDT
I had omitted to watch this bug until now. Sorry Simon for the duplicate content and for not starting from your branch eventually.
Comment 6 Thomas Watson CLA 2011-10-17 14:24:42 EDT
(In reply to comment #5)
> I had omitted to watch this bug until now. Sorry Simon for the duplicate
> content and for not starting from your branch eventually.

Hugues, Notice that Simon has a branch with the latest changes on github at https://github.com/simonjarcher/rt.equinox.bundles/tree/sarcher/servlet30
Comment 7 Thomas Watson CLA 2011-10-17 14:35:54 EDT
*** Bug 357286 has been marked as a duplicate of this bug. ***
Comment 8 Thomas Watson CLA 2011-10-18 09:11:31 EDT
From bug361022 comment7:  Chris writes:


The only help bundle a minimal RCP app needs is org.eclipse.help, which is
still at J2SE 1.4. Without a web server the other help bundles are not going to
be of much use to an RCP application. At the risk of digressing from the
original bug description I wanted to note some other possible cases of backward
incompatibility for help system clients.

There are two situations where help could end up using server other than the
Jetty version which ships with the SDK. One is when the user creates a war file
version of the help infocenter following instructions which are in the help
documentation. The other is if the extension point org.eclipse.help.base.server
is used to swap in a different help server. Both cases need to be tested and if
either or both does not work with servers which do not support Servlet 3.0 (
which seems quite possible ) we need to figure out a fallback strategy.

For the webapp as war file we can simply recommend that users that want to host
the war file on an older server should use Eclipse 3.8. The
org.eclipse.help.base.server extension point is a different story and will need
more investigation.
Comment 9 Thomas Watson CLA 2011-10-18 09:16:57 EDT
(In reply to comment #8)
> From bug361022 comment7:  Chris writes:
> 
> 
> The only help bundle a minimal RCP app needs is org.eclipse.help, which is
> still at J2SE 1.4. Without a web server the other help bundles are not going to
> be of much use to an RCP application. At the risk of digressing from the
> original bug description I wanted to note some other possible cases of backward
> incompatibility for help system clients.
> 
> There are two situations where help could end up using server other than the
> Jetty version which ships with the SDK. One is when the user creates a war file
> version of the help infocenter following instructions which are in the help
> documentation. The other is if the extension point org.eclipse.help.base.server
> is used to swap in a different help server. Both cases need to be tested and if
> either or both does not work with servers which do not support Servlet 3.0 (
> which seems quite possible ) we need to figure out a fallback strategy.

Our fall back strategy has been to use a proxy in the org.eclipse.equinox.http.servlet and org.eclipse.equinox.jsp.jasper bundles which need to implement things like the ServletContext.  The ServletContext got a lot of new methods added in Servlet 3.0.  Instead of implementing the ServletContext directly we now use a proxy so that we don't get bitten every time a new method is added to this interface.  This allows our support for the HttpServlet and JSP to work on the older Servlet 2.x versions and the JSP < 2.2 versions as well as the latest versions of Servlet and JSP.

> 
> For the webapp as war file we can simply recommend that users that want to host
> the war file on an older server should use Eclipse 3.8.

I think you meant Eclipse 3.7, but I disagree anyway.  The equinox bundles that make up the servlet bridge war should be able to run on both a Servlet 2.x and Servlet 3.0 containers.

> The org.eclipse.help.base.server extension point is a different story and will need
> more investigation.

I agree, anything you can point Simon A. at to investigate/test?
Comment 10 Thomas Watson CLA 2011-10-18 09:23:35 EDT
(In reply to comment #8)
> From bug361022 comment7:  Chris writes:
> 
> 
> The only help bundle a minimal RCP app needs is org.eclipse.help, which is
> still at J2SE 1.4. Without a web server the other help bundles are not going to
> be of much use to an RCP application.

If an RCP application must run on J2SE 1.5 or less and have support for the help web app then they are always free to package the jetty 6, servlet 2.x, jsp 2.1, jasper 5 bundles that we used in 3.7 on top of the Juno release.
Comment 11 Simon Archer CLA 2011-10-18 10:57:26 EDT
Here are all my changes to date that have been pushed to:
https://github.com/simonjarcher/rt.equinox.bundles/commits/sarcher/servlet30

-- Oct 14, 2011
0264729e44173a17a5acaac6d6b02d83d878be97
(Added optional import package statements for javax.servlet.annotation and
javax.servlet.descriptor.)

05061131ff99819ac4b8cc9757b3baf3fdaede81
(Added optional import package statements for javax.servlet.annotation and
javax.servlet.descriptor.)

d3b7332548dcb5a187c00aec3b1fa2b1e947cd55
(Fixed warnings about synthetic methods in JspServlet.ServletContextAdaptor.)

b46e79d2c1332425e40c4ba42cde4f77949cdfb6
(Fixed warning about synthetic method in invoke method.)

-- Oct 10, 2011
2c698485a085da2f860bd4861bd88f0007dadddc
(Applied polish.)

30689578330be4bb49701aef6e0cd89adad1a8df
(Applied polish.)

-- Oct 6, 2011
3226bef83e295069111efc0df8443383ce63c043
(Simplify proxy implementation.)

069eef013d86909b0fa26a44f6f744d3213da893
(Update exported javax.* package versions to [2.3,3.1).)

b65b3c2bffd5358041a0cebc19e01e25ec61e16a
(Initial changes for https://bugs.eclipse.org/bugs/show_bug.cgi?id=341643.)
Comment 13 Thomas Watson CLA 2011-10-19 17:47:17 EDT
Marking this as fixed.  Simon please open a separate bug for contributing tests.
Comment 14 Thomas Watson CLA 2012-03-19 11:36:58 EDT
*** Bug 374621 has been marked as a duplicate of this bug. ***