Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Stopping jetty when web app is unavailable.

The .startWithUnavailable(boolean) option is an old school concept, from back in the Jetty 7.0.0 days (circa 2008)

What it does is allow the WebAppContext to continue running if any Servlet init failed (from a servlet / filter / listener / etc) to initialize.
This value is set to false by default.
This is not what you want.

The .throwUnavailableOnStartupException(boolean) is a configuration related to a single WebAppContext.
It will collect all of the various reasons the webapp failed to init and then report it as a single Throwable on startup.
The key here is "on startup".
By default, the DeploymentManager will "on startup" deploy what it finds, then start monitoring the configured directories for changes and perform hot deploys.
The "on startup" part of this will throw an exception up to the Server and let the server know that something failed.

But if you have a hot deploy, then this exception is logged, and the WebAppContext is set to unavailable, but nothing else.

Now, for the sad part, the way that the XML is loaded in `jetty-home` (or the older `jetty-distribution`) all webapps are considered "hot deploy"
I've opened an issue about this at https://github.com/eclipse/jetty.project/issues/3620

Joakim Erdfelt / joakim@xxxxxxxxxxx


On Wed, May 1, 2019 at 11:30 AM Pavel <free.lan.c2.718r@xxxxxxxxx> wrote:

Hello everyone.

The goal I'm struggling to achieve is stopping jetty if my web app is unavailable:

2019-05-01 16:17:30.339:INFO:oejs.Server:main: jetty-9.4.5.v20170502
2019-05-01 16:17:30.363:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:///usr/local/jetty-distribution-9.4.5.v20170502/webapps/] at interval 1
2019-05-01 16:17:34.435:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=3706ms
2019-05-01 16:17:34.436:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@6a024a67{/rest,file:///usr/local/jetty-distribution-9.4.5.v20170502/work/jetty-0.0.0.0-8406-rest.war-_
rest-any-/webapp/,UNAVAILABLE}{/rest.war}

I guess `startWithUnavailable` config option is what I'm looking for, but apparently I'm not setting it correctly. Can someone please tell me how the xml should look like and where to place it?

Another option I found is `throwUnavailableOnStartupException` (set in jetty-env.xml). That works in that the exception bubbles up from WebAppContext - https://github.com/eclipse/jetty.project/blob/jetty-9.4.5.v20170502/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java#L557, but according to logs it stops at https://github.com/eclipse/jetty.project/blob/jetty-9.4.5.v20170502/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java and jetty remains running.

Any help is much appreaciated. Thank you!

Sincerely, Pavel

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

Back to the top