Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Start up order of contexthandlers / jetty maven plugin app?

Hi Jan,

Thank you for the quick reply, that was exactly what I was looking for! :)

The portal app still does not pick up my own portlets, but now I can cross the jetty config off the list and figure out the next piece of the puzzle.


On Tue, Dec 3, 2013 at 12:49 AM, Jan Bartel <janb@xxxxxxxxxxx> wrote:

If you use a jetty xml file and set up the handler structure in there,
and add in the webapp you want started first, the webapp that is the
subject of the jetty:run command will always be appended to the
context handler collection last. The context handler collection starts
up the contexts serially, in the order they appear in the collection.

Testing with jetty-9.1, here's an example jetty.xml file:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
<Configure id="Server" class="org.eclipse.jetty.server.Server">

    <Set name="handler">
      <New id="Handlers"
        <Set name="handlers">
         <Array type="org.eclipse.jetty.server.Handler">
             <New id="Contexts"
             <New id="DefaultHandler"

    <Ref refid="Contexts">
      <Call name="addHandler">
          <New class="org.eclipse.jetty.webapp.WebAppContext">
            <Set name="contextPath">/other</Set>
            <Set name="war">other.war</Set>


And here's the pom.xml snippet:

I've added ServletContextListeners for both webapps that just prints
out "contextInitialized" along with the ServletContextEvent, and
here's the startup log output  confirming /other was started before

2013-12-03 10:31:25.537:INFO:oejs.Server:main: jetty-9.1.1-SNAPSHOT
2013-12-03 10:31:25.830:INFO:oejsh.ContextHandler:main: Started
2013-12-03 10:31:26.518:INFO:oejsh.ContextHandler:main: Started
2013-12-03 10:31:26.537:INFO:oejs.ServerConnector:main: Started
[INFO] Started Jetty Server

So that confirms things are starting up in the right order.

I think you'll have to dig a bit into the portal application to see
how it completes its startup. Perhaps you could try running it in
maven using the jetty:deploy-war goal (see
for how to configure your pom) to check if it deploys ok by itself.


On 3 December 2013 09:50, Chris Poulsen <mailinglist@xxxxxxxxxx> wrote:
> Hi,
> I'm trying to get the jetty:run target of the maven jetty plugin to start up
> a dependency war before starting the normal webapp.
> Basically I'm trying to startup a portlet container prior to deploying the
> portlets from the project.
> I've tried a lot of different things (and a ton of jetty versions), but to
> no avail.
> If I specify a jetty.xml that adds a WebAppContext for the portal into the
> ContextHandlerCollection it looks like the portal is starting up before the
> app from the plugin (console output from portal first), but things does not
> look correct in the deployed portal after entire server is started. (the
> plugin webapp is deployed, but not registered in the portal - that mostly
> happens when the portal app isn't started first).
> Is there a way that I can ensure that the portal war is started before the
> webapp in the maven plugin? (it seems that the portal just needs to be
> initialized first, both apps seem to deploy correctly when i start a normal
> server containing both wars - god knows what determines the order in that
> case)
> --
> Chris
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx

Jan Bartel <janb@xxxxxxxxxxx>
'Expert Jetty/CometD developer,production,operations advice'
jetty-users mailing list

Back to the top