0

I have a jar type project. This jar is an "extension module" which goes to WEB-INF/lib of a third party webapp (which is available on a public maven repo). In pom.xml, I have a war type dependency on that webapp.

I would like to be able run mvn jetty:run-forked on the unextracted war file (straight from ~/.m2/repository while adding the projects dependencies and jar artifact "virtually" to WEB-INF/lib. Doing that seemed simpler than expected as jetty initialization gets quite convoluted. I ended up messing with the jetty/maven Java source code effectively reprogramming the initialization in XML. :) Finally from looking at http://wiki.eclipse.org/Jetty/Zip_Exceptions_Reading_Jar_or_War_Files there is further trouble ahead. In fact, it seems running unexploded wars is not possible for non trivial webapps (due to "File not resolvable or incompatible with URLClassloader").

Given the current jetty/maven source, is this possible at all?

What needs to be done to get it working?

Andreas Steffan
  • 5,731
  • 2
  • 21
  • 25

1 Answers1

0

You could repackage the webapp WAR with your extension module inside and run that. You would need to:

  1. Change your extension module's packaging type to WAR but have Maven still package your classes in a JAR (which goes inside the WAR) with archiveClasses = true.
  2. Use maven-war-plugin's overlay function to insert your module's JAR in the webapp WAR.
  3. Run Jetty on the resulting WAR.
Kolargol00
  • 1,361
  • 1
  • 12
  • 20
  • I cannot get jetty (9.2.2) to run any war file unexploded (extractWAR set to false) at all. It blows up with "File not resolvable or incompatible with URLClassloader" because it seems unable to deal with jars in wars. Besides, what I am really after is speed. I want to avoid extracting and repackaging an 150MB war file. Does extractWAR=false work for you when the war has jars in WEB-INF/lib ? – Andreas Steffan Aug 17 '14 at 15:43
  • @AndreasSteffan One of my builds did the unpacking/repacking trick twice on a 35MB WAR file. Not as big as yours but the speed was bearable. I haven't tried Jetty with unexploded WARs recently. If you can provide a minimal POM, I'll give it a try. – Kolargol00 Aug 18 '14 at 04:27