last day (14 days later) » 

5:48 PM
0
A: Embedding Jetty 9.3 with modular XmlConfiguration

Joakim ErdfeltOrder is extremely important when loading the Jetty XML files. That's the heart of what the entire start.jar and its module system is about, have an appropriate set of properties, the server classpath is sane, and ensuring proper load order of the XML. Note: its not possible to have everythi...

 
Is there any way that I can easily reuse/call function code from start.jar in my embedded app, where I can present it with a list of XML files and it can figure out the order etc for me?
 
you can't have start.jar work with just xml files. it has to work with modules.
you are embedded, declare the xml load order in your embedded code and use it. no need to be dynamic about it.
 
Well yes we embed Jetty. But it is useful to us if people can modify the Jetty config by just adding/changing XML files in our jetty/etc folder. Could we perhaps adopt the module mechanism from start.jar as well?
 
the start.jar uses a ${jetty.base} to handle modification needs to ${jetty.home} content. (Note: do not change/edit/modify/delete content in the ${jetty.home} directory)
 
Can I not just set $jetty.base = $jetty.home, and somehow use functions from start.jar to determine what to load?
 
5:49 PM
That's not recommended, in fact there's a specific error/warning produced when you do that.
future versions of Jetty will not allow that too.
 
6:27 PM
Okay, so it sounds like there is no good way for me to reuse the modular logic from start.jar in my embedded app then. That's a shame
 
You can use the module system
but it comes with requirements
such as a split between jetty.home and jetty.base
no editing of the jetty.home files
check out the test cases on the jetty-start project to see various ways you can use the start.jar classes to manage it
or you can just trigger a java runtime execution of start.jar too
the key classes to pay attention to ... BaseHome (manages the split between jetty.base and jetty.home) ... StartArgs (handles the argument loading / choices from the command line, ${jetty.base}/start.ini, and ${jetty.base}/start.d/*.ini files)
then there's the Main class too.
once you have the BaseHome defined properly, and the StartArgs populated, you can then interrogate the StartArgs for the properties, libs, and xml files you want/need.
but seriously, you are really overcomplicating things
you are attempting to use embedded-jetty to run jetty-distribution which itself is an embedded-jetty
just skip the jetty-distribution step entirely, use embedded-jetty directly
or use jetty-distribution as intended
but trying to mix things is not future proof
jetty 9.4 changes things here again, making the deprecation for conjoined jetty.home and jetty.base even more important.
jetty 10.x (in progress) using Servlet 4.x and Java 9 will make the jetty.home and jetty.base split mandatory
you can also, just take jetty-start and fork it for your purposes
replacing the role of jetty-start entirely
but know that jetty-start is jetty version specific, so you are then on the hook for maintaining that fork
chances are, if you could describe your requirements better, the answer is that you really no longer need embedded-jetty for your hybrid/bootstrap setup. just use the jetty-distribution as intended. (it supports tiered configurations, multiple instances per jetty-distribution, multi-tenant, easier upgrades, etc.)
 
7:42 PM
Thanks Joakim that is all good advice. I already figured I could probably use a jetty-distribution and create a module for my app. However I think right now that would be too much disturbance for our users (eXist-db)
On a slightly separate note. Any idea if this NPE is a bug in Jetty 9.3.9 or bad config on my part - 2016-06-15 20:40:14,705 [eXistThread-56] WARN (HttpChannel.java [handle]:479) - //localhost:8080/exist/apps/dashboard/index.html
java.lang.NullPointerException
at org.eclipse.jetty.server.RequestLogCollection.log(RequestLogCollection.java:44) ~[jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
at org.eclipse.jetty.server.HttpChannel.onCompleted(HttpChannel.java:620) ~[jetty-server-9.3.9.v20160517.jar:9.3.9.v20160517]
 

last day (14 days later) »