Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366092 - Jetty server WebAppContext missing from Eclipse 4.2
Summary: Jetty server WebAppContext missing from Eclipse 4.2
Status: RESOLVED FIXED
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: wst.server (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 3.4.2   Edit
Assignee: Steven Hung CLA
QA Contact: Elson Yuen CLA
URL:
Whiteboard: PMC_approved
Keywords:
: 387368 (view as bug list)
Depends on: 379180
Blocks:
  Show dependency tree
 
Reported: 2011-12-08 14:26 EST by Elson Yuen CLA
Modified: 2017-10-11 16:39 EDT (History)
6 users (show)

See Also:
eyuen7: pmc_approved? (david_williams)
raghunathan.srinivasan: pmc_approved+
eyuen7: pmc_approved? (naci.dai)
eyuen7: pmc_approved? (neil.hauge)
eyuen7: pmc_approved? (kaloyan)
cbridgha: pmc_approved+


Attachments
Use WebAppContext v1 (3.14 KB, patch)
2012-08-17 04:10 EDT, Zach Lipton CLA
sghung: iplog+
Details | Diff
Patch v1.0 Plug-in and Feature changes (6.27 KB, patch)
2013-01-16 11:30 EST, Steven Hung CLA
eyuen7: review+
Details | Diff
Patch v1.0 for releng changes (1.01 KB, patch)
2013-01-16 11:32 EST, Steven Hung CLA
eyuen7: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elson Yuen CLA 2011-12-08 14:26:18 EST
When working on the build breakage bug 365681, I find that the WebAppContext is missing from Eclipse 4.2 post-M3.  I have temporarily switched to use org.eclipse.jetty.server.handler.ContextHandler.  However, it may causes reduction in function on dynamic web project case.

This defect is to address the problems that may be introduced by the fix on 365681 after resolving the build issue.
Comment 1 Steven Hung CLA 2012-05-14 15:58:59 EDT
This is a duplicate of Bug 379180.

org.eclipse.jetty.webapp is currently not in Juno and that is where WebAppContext is now located at.
Comment 2 Steven Hung CLA 2012-05-14 15:59:20 EDT

*** This bug has been marked as a duplicate of bug 379180 ***
Comment 3 Steven Hung CLA 2012-05-14 16:06:50 EDT
I am re-opening this bug, to track the changes on the server tools side, once the missing plug-ins have been added from Bug 379180.
Comment 4 Steven Hung CLA 2012-05-14 16:09:48 EDT
Jan B had written in Bug 379180:

If you were using a WebAppContext with jetty-6, then you should continue to use
one for jetty-7/8, as this is the correct way to set up a web app in jetty. The
ContextHandler is intended for lighter-weight setups without the full support
for webapps (ie sessions, servlets, WEB-INF/web.xml etc etc).

Therefore, we cannot use ContextHandler, we need to use WebAppContext. I have tested and it is true, servlets will not work when using ContextHandler.
Comment 5 Zach Lipton CLA 2012-08-17 04:09:24 EDT
After a good deal of searching and debugging, I just came across this bug. The issue I've been having is that under Juno is that any of my servlet projects are broken in the J2EE Preview server, even though the same projects and configuration worked fine in Indigo. The root cause appears to be the same issue discussed in this bug. It appears to be a pretty critical issue, as it basically breaks the J2EE Preview server in Juno for many types of deployments. 

I just hacked around a bit and cobbled together a patch (attached) that moves the preview server back to using WebAppContext and takes care of the dependencies accordingly. This resolves the issue for me. I'm completely ignorant when it comes to Eclipse internals, so there may well be other packaging or dependency issues that I haven't considered, but this was enough to get things working again on Juno for me.
Comment 6 Zach Lipton CLA 2012-08-17 04:10:02 EDT
Created attachment 219992 [details]
Use WebAppContext v1
Comment 7 Elson Yuen CLA 2012-08-23 12:45:18 EDT
*** Bug 387368 has been marked as a duplicate of this bug. ***
Comment 8 Elson Yuen CLA 2012-08-23 12:46:32 EDT
Raising to major because of the impact of this defect.
Comment 9 Elson Yuen CLA 2012-08-23 14:23:02 EDT
Zach, thanks or submitting the patch. 

The main problem is Eclipse has stopped shipping those plugins starting from Juno. That's why the plugins org.eclipse.jetty.xml and org.eclipse.jetty.webapp are missing from the WTP package.  WTP picked up those plugins from base eclipse in the past (see bug 379180) for details.  We are trying to figure out to see if we can package those classes as part of WTP before we can make those code changes to fix the problem.
Comment 10 Steven Hung CLA 2013-01-16 11:30:49 EST
Created attachment 225714 [details]
Patch v1.0 Plug-in and Feature changes

The patch code changes are based on Zach's code changes. My change is to get the Jetty plug-ins added into Eclipse as part of the server tools WTP installation.

To get the missing Jetty plug-ins, an approach is used similar to what Dali does in their feature file and map file in order to pull in additional plug-ins. I use:

plugin@org.eclipse.jetty.webapp,8.1.3=p2IU,id=org.eclipse.jetty.webapp,version=8.1.3.v20120522,repository=http://download.eclipse.org/jetty/updates/jetty-bundles-8.x/8.1.3.v20120522
plugin@org.eclipse.jetty.xml,8.1.3=p2IU,id=org.eclipse.jetty.xml,version=8.1.3.v20120522,repository=http://download.eclipse.org/jetty/updates/jetty-bundles-8.x/8.1.3.v20120522

In the map file and use the specific repository to match the Jetty plug-ins with what WTP 3.4.2 uses.

In the org.eclipse.wst.server.preview's feature.xml, I add references to org.eclipse.jetty.webapp and org.eclipse.jetty.xml.

Note: The JSPs are still broken by Bug 377886 

Tests run with J2EE preview server:
1. DWP 2.5, successfully able to run servlet
2. DWP 3.0, was not able to run servlet. More investigation is required
Comment 11 Steven Hung CLA 2013-01-16 11:32:46 EST
Created attachment 225715 [details]
Patch v1.0 for releng changes

The patch for releng changes, that could not be added to the previous patch. This patch does not include the tag updates that will be applied when committing the changes.
Comment 12 Steven Hung CLA 2013-01-16 12:24:58 EST
Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such.
The J2EE preview server is broken on Juno. In particular, the servlets cannot be run due to Jetty changes in Juno.

Is there a work-around? If so, why do you believe the work-around is insufficient?
No, there is no workaround. The problem is caused by missing plug-ins.

How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added?
The fix has been tested through manual tests. Servlets and HTML files were tested on Dynamic Web Projects 2.5 to ensure they run properly. JSPs still fail due to the error from Bug 377886, which needs to be investigated further. No new JUnit tests were added.

Give a brief technical overview. Who has reviewed this fix?
In order to use WebAppContext (which will allow servlets to work), the plug-ins org.eclipse.jetty.webapp and org.eclipse.jetty.xml need to be added as dependencies. These plug-ins are not part of the WTP by default, so the feature and releng files need to be updated to pull in these plug-ins.

The code changes were reviewed by Elson Yuen. The feature and releng file changes to pull in the Jetty plug-ins were based on recommendations from David Williams and looking at what Dali does.

What is the risk associated with this fix?
Medium, the feature and releng changes needs to be tested through a build to ensure there is no build breakages caused by pulling in the additional Jetty plug-ins.

The code change itself is low, since it just affects the J2EE preview server.
Comment 13 Steven Hung CLA 2013-01-16 12:28:14 EST
Comment on attachment 219992 [details]
Use WebAppContext v1

I am marking this patch as obsolete because my new changes are based on these changes. The only change I made to this patch is related to the copyright header.

My other two patches deal with the feature and releng changes required to pull in the missing Jetty plug-ins.
Comment 14 Chuck Bridgham CLA 2013-01-16 13:50:33 EST
approved - we def want this working again.
Comment 15 Steven Hung CLA 2013-01-17 10:55:41 EST
Released to 3.4.2
Comment 16 Steven Hung CLA 2013-01-17 15:54:33 EST
I verified with wtp4x-R3.4.2-M/20130117161135 that the J2EE preview server works with a dynamic web project (version 2.5). 

I also verified that org.eclipse.jetty.webapp and org.eclipse.jetty.xml are installed as part of WTP 3.4.2
Comment 17 Steven Hung CLA 2013-01-23 18:30:25 EST
Code released to HEAD. I also changed 3.4.2 map file to point to the tags with changes done on the master branch, since the 3.4.2 maintenance and master branch currently use the same code
Comment 18 Eclipse Genie CLA 2017-10-11 16:39:31 EDT
New Gerrit change created: https://git.eclipse.org/r/109151
Comment 19 Eclipse Genie CLA 2017-10-11 16:39:33 EDT
New Gerrit change created: https://git.eclipse.org/r/109150