Convert context.xml from Tomcat to Jetty

I have the following context.xml in webapp / META-INF /. This is used by tomcat to determine the value to be understood using Spring with Property

<?xml version="1.0" encoding="UTF-8"?> <Context> <Parameter name="si.host" value="super.com" override="false"/> </Context> 

Right now I'm trying to deploy webapp with the maven plugin:

  <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.26</version> <configuration> <connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>8080</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> <jettyEnvXml>${basedir}\src\test\resources\server\jetty\jetty-env.xml</jettyEnvXml> <jettyConfig>${basedir}\src\test\resources\server\jetty\jetty.xml</jettyConfig > <contextPath>/myapp</contextPath> <webApp>target/myapp.war</webApp> <stopKey>foo</stopKey> <stopPort>9999</stopPort> </configuration> <executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> <daemon>true</daemon> </configuration> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> 

How to add this parameter to jetty.xml?
I already dig into their documentation, and here in google, but I didn’t understand anything. Thanks in advance for your help.

+4
source share
2 answers

Thanks first to DogBane !!

I found another solution without having to modify web.xml Use the default web.xml file.

This file is applied to the web application before its own WEB_INF / web.xml file.

I prefer this than using jetty.xml because it is less verbose.

Just add the webDefaultXml file with the path to the file below to the maven plugin configuration section:

 <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns /javaee/web-app_2_5.xsd" metadata-complete="true" version="2.5"> <description> Default web.xml file. This file is applied to a Web application before it own WEB_INF/web.xml file </description> <context-param> <param-name>si.host</param-name> <param-value>super.com</param-value> </context-param> </web-app> 
+2
source

This needs to be done in WEB-INF/web.xml , which is independent of the web server, i.e. It will work both in tomcat and in the pier:

 <context-param> <param-name>si.host</param-name> <param-value>super.com</param-value> </context-param> 

or you can install it in your XML file attach as follows:

 <Configure class="org.mortbay.jetty.webapp.WebAppContext"> ... <Set name="initParams"> <Map> <Entry> <Item>si.host</Item> <Item>super.com</Item> </Entry> </Map> </Set> </Configure> 
+7
source

Source: https://habr.com/ru/post/1338814/


All Articles