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.

--
Chris



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

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"
"http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">

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


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

</Configure>

And here's the pom.xml snippet:
     <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.1.0.v20131115</version>
        <configuration>
          <jettyXml>jetty-main.xml</jettyXml>
          <webApp>
            <contextPath>/test</contextPath>
          </webApp>
        </configuration>
      </plugin>

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
/test:

2013-12-03 10:31:25.537:INFO:oejs.Server:main: jetty-9.1.1-SNAPSHOT
contextInitialized
javax.servlet.ServletContextEvent[source=ServletContext@o.e.j.w.WebAppContext@72767cfb{/other,file:/tmp/jetty-0.0.0.0-0-other.war-_other-any-6758067937025345951.dir/webapp/,STARTING}{other.war}]
2013-12-03 10:31:25.830:INFO:oejsh.ContextHandler:main: Started
o.e.j.w.WebAppContext@72767cfb{/other,file:/tmp/jetty-0.0.0.0-0-other.war-_other-any-6758067937025345951.dir/webapp/,AVAILABLE}{other.war}
contextInitialized
javax.servlet.ServletContextEvent[source=ServletContext@o.e.j.m.p.JettyWebAppContext@422442a6{/test,file:/home/janb/src/jetty-eclipse/jetty-9/tests/test-webapps/test-jetty-webapp/src/main/webapp/,STARTING}{file:/home/janb/src/jetty-eclipse/jetty-9/tests/test-webapps/test-jetty-webapp/src/main/webapp/}]
2013-12-03 10:31:26.518:INFO:oejsh.ContextHandler:main: Started
o.e.j.m.p.JettyWebAppContext@422442a6{/test,file:/home/janb/src/jetty-eclipse/jetty-9/tests/test-webapps/test-jetty-webapp/src/main/webapp/,AVAILABLE}{file:/home/janb/src/jetty-eclipse/jetty-9/tests/test-webapps/test-jetty-webapp/src/main/webapp/}
2013-12-03 10:31:26.537:INFO:oejs.ServerConnector:main: Started
ServerConnector@3266589{HTTP/1.1}{0.0.0.0:8080}
[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
http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html#deploy-war-running-pre-assembled-war
for how to configure your pom) to check if it deploys ok by itself.

cheers
Jan

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
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
'Expert Jetty/CometD developer,production,operations advice'
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top