Home:ALL Converter>Jetty 6 to Jetty 9 Context Deployer migration

Jetty 6 to Jetty 9 Context Deployer migration

Ask Time:2015-01-22T04:09:21         Author:user1013905

Json Formatter

Migrating from Jetty 6 to 9 has been much harder than what I originally thought but I have got a lot of it done thanks to the resources you all have online

I question that I have not found xml examples online regarding Embedded Servlets in Jetty 9 other than the link below

http://jetty.4.x6.nabble.com/Jetty-9-Context-Deployer-td4960157.html

First off, it seems that you all have migrated from ContextDeployer to WebAppProvider is this a correct statement?

I ask this because in Jetty6, I was able to use a context deployer to search a directory to configure servlets as context objects. Since ContextDeployers seem to be gone, the closest usage in Jetty I see is the WebAppProvider which opens webpages from a war file. This isn't what my company wants to do and we would like to be able to use contexts in the same way we have done in the past

Now I have seen the ServletContextHandler which seems simple enough to configure and would act as the context object. However, my current web app provider configuration will not open my servlet web pages

Here is an excerpt of how I use the DeployManager in xml

<Call name="addBean">
<Arg>
  <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
    <Set name="contexts">
      <Ref refid="Contexts" />
    </Set>

    <Call id="webappprovider" name="addAppProvider">
      <Arg>
        <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
          <Set name="monitoredDirName"><Property name="jetty.home" default="config/jetty/context/"/></Set>
          <Set name="scanInterval">5</Set>
        </New>
      </Arg>
    </Call>
  </New>
</Arg>

An example Servlet configuration xml

<Configure id="contexts" class="org.eclipse.jetty.servlet.ServletContextHandler">
  <Set name="contextPath">/</Set>
  <Call name="addServlet">
    <Arg>class.name.here</Arg>
    <Arg>/*</Arg>
  </Call>
</Configure>

Author:user1013905,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28075956/jetty-6-to-jetty-9-context-deployer-migration
yy