Curious, is it possible to run an embedded jetty with an exploded war file? (This will make uploaded a specific jar to production faster since the file payload is less than having to push the entire .war file)
On Thu, Feb 28, 2013 at 7:22 AM, S Ahmed <[email protected]> wrote: > According to this article: > http://jowisoftware.de/blog/archives/26-Creating-runnable-wars-with-Maven-and-Jetty.html > > When trying to run: > > java -jar myproject.war > > I get the main-class error: > > Exception in thread "main" java.lang.NoClassDefFoundError: > com/myprjoect/path/to/main/ClassName > > According to that article the issue is: "The problem is easy to > understand: when starting Java with -jar, it expects a "normal" file > structure. So if the Main-Class is "de.jowisoftware.Main", Java looks for > de/jowisoftware/Main.class. The classloader does not understand the > concept, that, in war files all class files are in WEB-INF/classes. If > jetty is included in the war file, it is included as a jar file, so the > classloader has to support nested archives. The default one doesn't. > Thankfully, there are solutions." > > What options do I have, is it basically how the author of the blog posts > states? > > Or is the alternative ways to embedding jetty and then launching it? > > > I have this: > > ProtectionDomain protectionDomain = HttpServer.class.getProtectionDomain(); > String warFile = > protectionDomain.getCodeSource().getLocation().toExternalForm(); > String currentDir = new > File(protectionDomain.getCodeSource().getLocation().getPath()).getParent(); > > WebAppContext webAppContext = new WebAppContext(warFile, > contextPath); > > resetTempDirectory(webAppContext, currentDir); > > webAppContext.setParentLoaderPriority(true); > server.setHandler(webAppContext); > > server.start(); > server.join(); > >
_______________________________________________ jetty-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/jetty-users
