Advice about embedding Jetty into a large existing app

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Advice about embedding Jetty into a large existing app

Shawn Heisey
I'm from the Solr project.  This is a large application that currently
ships with scripts that start Jetty to get Solr running.  I would like
to have Solr be its own application.  The quickest path to that is to
embed Jetty into Solr.

https://issues.apache.org/jira/browse/SOLR-6733

Some of the reasons for doing this are indirectly referenced here:

https://wiki.apache.org/solr/WhyNoWar

A little while ago I asked some questions on the freenode #jetty IRC
channel.  Since it's evening in the USA as I write this, I am not
expecting anyone on the channel to see what I've asked until tomorrow,
so I thought I would move the discussion here.

Here's a transcript of my questions from IRC:

19:06 < elyograg> first big question: are there guides for doing this that I
                   can read?
19:09 < elyograg> I did find the "Embedding Jetty" section of the jetty
docs,
                   and I will read that.  But I'm also interested in a
quicklist
                   of dos and don'ts.
19:10 < elyograg> a question that's clearly NOT on-topic, but I need to ask
                   somewhere:  How do I go about creating
solr-start.jar?  How
                   do I do this within an existing (and COMPLICATED) ant
build
                   system?
19:13 < elyograg> when embedding jetty, do things associated with the full
                   jetty app (like lib/ext) disappear?  I would guess
that they
                   do, just looking for confirmation.

Any advice?  I have read the 'Embedding Jetty' page now.  It looks like
most of the meat of that is in the source code examples, which I haven't
fully digested yet.

I think that all of Solr's handlers are accessed through a class that we
call SolrDispatchFilter.

I'm sure I will have lots of really dumb questions once the work really
gets underway.  I can do most of that on the IRC channel.

To anyone who might respond: If you'd prefer to use IRC, I'm there. 
Can't guarantee that I'll be watching it, but I do have full access to
the channel history once I get back to it.

Thanks,
Shawn

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Advice about embedding Jetty into a large existing app

Greg Wilkins

Shawn,

It's difficult to give a definitive answer to your questions because there are so many possibilities.  A couple of points:
  • When a jetty distribution is configured in XML, it is essentially just writing java code in XML that creates some objects, calls some setters, then calls the start method.  So anything that can be done in the distribution XML can be done in code.
  • LikeJettyXml is an embedded example that sets up pretty much the full server just as jetty.xml does.
  • The start.jar is a different matter, as it's job is to build a classpath and a list of XMLs to execute.  So you have to replace that by something  that will build your classpath (or a fat jar) and call a main method.   There are plugins for that kind of thing.  Things like lib/ext are really classpath stuff rather than config stuff.
  • You also might want to consider java 9/10/11 executable jars for this kind of thing.
It's not  really very difficult... other than there is perhaps too much flexibility so it can be hard to know which way to go.  My recommendation is to progress by:
  1. create a main method that initially just does hello world
  2. make the main method say "hello world "+some constant from a solr class
  3. Bundle up the main method and dependencies into an executable jar the way you want.
  4. Add "Server server = new Server(); server.start(); server.join();" to your main method
  5. Build on that by configuring the server in code until it does what you want.
cheers







On 17 May 2018 at 12:03, Shawn Heisey <[hidden email]> wrote:
I'm from the Solr project.  This is a large application that currently ships with scripts that start Jetty to get Solr running.  I would like to have Solr be its own application.  The quickest path to that is to embed Jetty into Solr.

https://issues.apache.org/jira/browse/SOLR-6733

Some of the reasons for doing this are indirectly referenced here:

https://wiki.apache.org/solr/WhyNoWar

A little while ago I asked some questions on the freenode #jetty IRC channel.  Since it's evening in the USA as I write this, I am not expecting anyone on the channel to see what I've asked until tomorrow, so I thought I would move the discussion here.

Here's a transcript of my questions from IRC:

19:06 < elyograg> first big question: are there guides for doing this that I
                  can read?
19:09 < elyograg> I did find the "Embedding Jetty" section of the jetty docs,
                  and I will read that.  But I'm also interested in a quicklist
                  of dos and don'ts.
19:10 < elyograg> a question that's clearly NOT on-topic, but I need to ask
                  somewhere:  How do I go about creating solr-start.jar?  How
                  do I do this within an existing (and COMPLICATED) ant build
                  system?
19:13 < elyograg> when embedding jetty, do things associated with the full
                  jetty app (like lib/ext) disappear?  I would guess that they
                  do, just looking for confirmation.

Any advice?  I have read the 'Embedding Jetty' page now.  It looks like most of the meat of that is in the source code examples, which I haven't fully digested yet.

I think that all of Solr's handlers are accessed through a class that we call SolrDispatchFilter.

I'm sure I will have lots of really dumb questions once the work really gets underway.  I can do most of that on the IRC channel.

To anyone who might respond: If you'd prefer to use IRC, I'm there.  Can't guarantee that I'll be watching it, but I do have full access to the channel history once I get back to it.

Thanks,
Shawn

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



--

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Advice about embedding Jetty into a large existing app

Shawn Heisey
On 5/16/2018 11:53 PM, Greg Wilkins wrote:
> It's difficult to give a definitive answer to your questions because
> there are so many possibilities.  A couple of points:

First, thank you for your response.  Anything I can get is probably
going to help me.

I am aware of very vague nature of what I'm asking.  I will be able to
come up with more specific questions once I start getting into the
work.  After reading the "Embedding Jetty" documentation page, I am
looking for something with a little more detail, maybe even a post where
somebody has documented something similar, embedding Jetty into a large
existing webapp project. Somewhere I can read about things that need
attention and things to avoid.

>   * When a jetty distribution is configured in XML, it is essentially
>     just writing java code in XML that creates some objects, calls
>     some setters, then calls the start method.  So anything that can
>     be done in the distribution XML can be done in code.
>   * LikeJettyXml is an embedded example that sets up pretty much the
>     full server just as jetty.xml does.
>

I'm not too worried about replacing jetty.xml, and even web.xml, with
code.  The embedding documentation is short, but I think the examples it
has are likely to cover that pretty well.  A lot of what worries me is
how to fix the build system.  I think I can ask fellow project members
for help with a lot of that.

>   * The start.jar is a different matter, as it's job is to build a
>     classpath and a list of XMLs to execute.  So you have to replace
>     that by something  that will build your classpath (or a fat jar)
>     and call a main method.  There are plugins for that kind of
>     thing.  Things like lib/ext are really classpath stuff rather than
>     config stuff.
>

I think you've confirmed my suspicion.  Sounds like most of the config
infrastructure related to a full Jetty install is handled by Jetty's
start code (with start.jar as the entry point), and I would have to take
care of that myself.

>   * You also might want to consider java 9/10/11 executable jars for
>     this kind of thing.
>

I'm torn on whether to require Java 9 with the next major version of
Solr.  It might be a good idea -- we could be close to (or maybe even
past) Java 8's end of public support date by the time that version of
Solr actually gets released.  I will research the executable jar feature.

Thanks,
Shawn

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Advice about embedding Jetty into a large existing app

Jesse McConnell

I'm torn on whether to require Java 9 with the next major version of
Solr.  It might be a good idea -- we could be close to (or maybe even
past) Java 8's end of public support date by the time that version of
Solr actually gets released.  I will research the executable jar feature.


Java 9 is basically dead already. :/



_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Advice about embedding Jetty into a large existing app

Shawn Heisey
On 5/18/2018 7:59 AM, Jesse McConnell wrote:

>
>
>     I'm torn on whether to require Java 9 with the next major version of
>     Solr.  It might be a good idea -- we could be close to (or maybe even
>     past) Java 8's end of public support date by the time that version of
>     Solr actually gets released.  I will research the executable jar
>     feature.
>
>
> Java 9 is basically dead already. :/
>
> https://webtide.com/java-updates-jetty-and-the-future/

That's an insanely fast release schedule for major versions.  If they're
really going to stick to that schedule, we might want to support and
require Java 12 with Solr 8!

Silly thought: Is Oracle trying to surpass Mozilla's version numbers?

Thanks,
Shawn

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Advice about embedding Jetty into a large existing app

Jesse McConnell
It is a bold new world! :)

On Fri, May 18, 2018, 9:12 AM Shawn Heisey <[hidden email]> wrote:
On 5/18/2018 7:59 AM, Jesse McConnell wrote:
>
>
>     I'm torn on whether to require Java 9 with the next major version of
>     Solr.  It might be a good idea -- we could be close to (or maybe even
>     past) Java 8's end of public support date by the time that version of
>     Solr actually gets released.  I will research the executable jar
>     feature.
>
>
> Java 9 is basically dead already. :/
>
> https://webtide.com/java-updates-jetty-and-the-future/

That's an insanely fast release schedule for major versions.  If they're
really going to stick to that schedule, we might want to support and
require Java 12 with Solr 8!

Silly thought: Is Oracle trying to surpass Mozilla's version numbers?

Thanks,
Shawn

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users