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

Bug 330189

Summary: Unassembled Servlet 3.0 Web Apps from folders & JARs anywhere on CP
Product: [RT] Jetty Reporter: Michael Vorburger <mike>
Component: serverAssignee: Jan Bartel <janb>
Status: CLOSED WORKSFORME QA Contact:
Severity: enhancement    
Priority: P3 CC: gregw, gsubes, janb, jetty-inbox, lgawron, mail, quinton.mccombs
Version: unspecified   
Target Milestone: 7.1.x   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
How I've worked around the current (by design) "limitation" (one class, full working example on github)
none
WebContextConfiguration showing how I've worked around the current (by design) "limitation" (one class, full working example on github)
none
MetaInfConfiguration showing how I've worked around the current (by design) "limitation" (one class, full working example on github)
none
FragmentConfiguration showing how I've worked around the current (by design) "limitation" (one class, full working example on github)
none
WebContextWithServletContextResourceExtension.java none

Description Michael Vorburger CLA 2010-11-13 18:55:33 EST
Build Identifier: 8.0.0.M1

It would be great if Jetty (v8 presumably) had built-in support for easily and efficiently developing "unassembled" Servlet 3.0 Web Apps, by being able to load META-INF/resources & web-fragment.xml from both folders & JARs, anywhere on classpath (e.g. within Eclipse on an m2e Maven Dependencies classpath container).

Currently this is not possible, because META-INF/resources & web-fragment.xml MUST be in JAR, and necessarily in WEB-INF/lib.

Please see http://dev.eclipse.org/mhonarc/lists/jetty-dev/msg00531.html, https://github.com/vorburger/EclipseWebDevEnv/tree/servlet30-jetty7 which illustrate the idea (in jetty-test/ the non-working example to better illustrate the idea, and in simpleservers/ a more complete full-fledged solution, which works, via Jetty Configuration class extensions), and/or feel free to contact me.

I have managed to get this to work through to some "extensions" of the standard Configuration classes, see https://github.com/vorburger/EclipseWebDevEnv/tree/servlet30/simpleservers/ch.vorburger.modudemo.server/src/main/java/ch/vorburger/modudemo/server/. I'll also attach them here. If this Enhancement proposal is accepted, the actual implementation would likely be somewhat different.

Reproducible: Always
Comment 1 Michael Vorburger CLA 2010-11-13 19:02:32 EST
Created attachment 183083 [details]
How I've worked around the current (by design) "limitation" (one class, full working example on github)
Comment 2 Michael Vorburger CLA 2010-11-13 19:03:25 EST
Created attachment 183084 [details]
WebContextConfiguration showing how I've worked around the current (by design) "limitation" (one class, full working example on github)
Comment 3 Michael Vorburger CLA 2010-11-13 19:03:48 EST
Created attachment 183085 [details]
MetaInfConfiguration showing how I've worked around the current (by design) "limitation" (one class, full working example on github)
Comment 4 Michael Vorburger CLA 2010-11-13 19:04:10 EST
Created attachment 183086 [details]
FragmentConfiguration showing how I've worked around the current (by design) "limitation" (one class, full working example on github)
Comment 5 Greg Wilkins CLA 2010-11-15 03:31:52 EST
Michael,

this is a great idea!

We'll have a ponder and look at what you have done and comment more soon.
Comment 6 Michael Vorburger CLA 2011-01-04 16:16:09 EST
Greg, thank you for the encouragement. Did you get a chance to "ponder" ;) yet? Can I help?

FYI: I'm currently integrating this approach for an enhanced workspace experience into http://mifos.org

In that context, I came across a... "funky problem" which is an impact of this solution that I initially hadn't considered, and that I wanted you to be aware of in case (hopefully) you'll integrate, something like, this: ServletContext.getResource() & getResourcePaths() has to be adapted for a now "virtualized" WEB-INF/lib. Have a look at https://github.com/vorburger/EclipseWebDevEnv/blob/servlet30-jetty7/simpleservers/ch.vorburger.modudemo.server/src/main/java/ch/vorburger/modudemo/server/WebContextWithServletContextResourceTrick.java (I'll also attach it) and I'm sure you guys will immediately understand.
Comment 7 Michael Vorburger CLA 2011-01-04 16:17:34 EST
Created attachment 186049 [details]
WebContextWithServletContextResourceExtension.java
Comment 8 Missing name CLA 2011-02-25 17:41:17 EST
thank you, this helped me a lot :)

I am using this to be able to start my modular webapp during development in eclipse and when the deployment is being done into a fat-jar which has jetty embedded and every class in the same jar packaged
Comment 9 Michael Vorburger CLA 2011-09-10 15:26:35 EDT
FTR: This approach is meanwhile heavily & successfully used in the workspace of the Mifos.org development community.  In case the links above ever go 404, following http://mifosforge.jira.com/wiki/display/MIFOS/Workspace+2.0 (or simply digging into the code at mifos.git.sourceforge.net) may be helpful.
Comment 10 Quinton McCombs CLA 2012-07-18 11:05:10 EDT
Any idea when this might get implemented?  

At my company, we have been developing web apps (normally war) for many years.  We spend lots of extra time making sure that our apps work in JBoss, WebLogic, and Websphere because our customers will expect to be able to deploy into their favorite app server.  Not to mention that customers will always find a way to misconfigure the server or deploy other wars into the same server instance.  The headaches never seem to end.....

I am piloting a program to use Jetty in embedded mode.  We will basically have a command line application which will start up Jetty to function as a servlet container.  So far, everything looks very promising except that developers are impacted since they can't run the app inside of their ide(s).  

In the mean time, it looks like I should be able to use these configuration classes provided by Michael (thanks by the way!!!).
Comment 11 Jan Bartel CLA 2015-05-27 01:32:27 EDT
Wow, this issue has been open for a long time. Sorry!

However, the good news is that I believe that these workarounds are no longer necessary with jetty-9 (in particular jetty-9.2 and above).  The code now handles either jars or directories on both the container path and the webapp path (via use of the WebAppContext.setExtraClassPath() method, see https://www.eclipse.org/jetty/documentation/current/jetty-classloading.html#using-extra-classpath-method).

I'm going to close this issue as a works-for-me for jetty-9.

cheers
Jan