Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Embedded Jetty, classpath-based META-INF/resources & web-fragment.xml, developer workspaces

I have meanwhile been able to solve points 1. - 3. below through some more debugging. 

On e.g. I have a fully working example of this approach now.

Also filed to may later track this.

On Tue, Nov 9, 2010 at 9:21 PM, Michael Vorburger <mike@xxxxxxxxxxxx> wrote:

I've been experimenting with Jetty v8 and META-INF/resources & web-fragment.xml for modularity & developer workspace productivity. -- At is a very simple sample project (I can ZIP and put it somehwere on HTTP if github is not convenient).

So mvn install in web-module/ puts a simple JAR with a Servlet, a META-INF/resources/index.txt and a META-INF/web-fragment.xml into the local repo.  Then mvn -DskipTests=true package in web-app builds a web-app.war.  Copy that webapps/ of an unzipped, then in jetty-distribution-8.0.0.M1/, launch via a java -jar start.jar; now on http://localhost:8080/web-app/index.txt & http://localhost:8080/web-app/SomeServlet all is as expected, great!  (Dito same WAR dropped into a Tomcat v7, all well.)

Now to the workspace... and a few questions.  Import jetty-test/web-app (only, not yet web-module, or close the Eclipse project) into an Eclipse with m2e, and Jetty v8 JARs and web-module-0.0.1-SNAPSHOT.jar appear on the Maven Dependencies classpath container.

1. How can web-fragment.xml be used with an embedded Jetty, to load from JARs on the (Eclipse, m2e) classpath?  As the SomethingWebTest illustrates, when launched from within Eclipse, the index.txt is actually served, but the SomeServlet is not... when launching with -D.DEBUG=true, note parsing ... web-module-0.0.1-SNAPSHOT.jar!/META-INF/web-fragment.xml, but then for some reason the Servlet isn't configured anyhow. I do understand that loading JARs from outside WEB-INF/lib isn't "standard", and I'm forcing it with my webAppContext.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*") in startServer() - and it works for (e.g. index.txt) resources!  It would be great for developer productivity if this was supported by Embedded Jetty... possible?

2. If one now imports / opens the web-module in Eclipse, m2e does its workspace resolution thing, and the JAR on the classpath of web-app is replaced by a folder.  Re-run SomethingWebTest, and now not even (e.g. index.txt) resources work anymore. I've debugged this one a bit, and understood it's because META-INF/resources is expected to be inside a packaged JAR - but why must it? In a workspace, it would be great if this worked out of the box!  I've actually managed to hack to get this one to work, see stuff around MetaInfFolderConfiguration in  Any chance (something like) this could be integrated?  I could do some clean-up and integrated into a MetaInfConfiguration patch - or you could rewrite completely to achieve the same functionality somehow differently.

3. When running mvn test in web-app, theapp/index.txt again cannot be found.  Do you think it's feasible to support this scenario?

Thanks a lot,

PS: I put up some more blurb about the approach/idea on
Michael Vorburger

Back to the top