Jetty;linux directory Structure

Source: Internet
Author: User

"description" Today looked at jetty this web container, the morning to see the basic theory framework knowledge (the slightest useless to the back), the afternoon downloaded jetty, and deployed a war application on the above, at night in the eclipses integration jetty, there is a problem, after downloading the plugin can not run, It also raises questions about how the jetty plug-in Works

One: Completed today

1) Jetty's official brief introduction

Jetty provides a Web server and Javax.servlet container, plus support for HTTP/2, WebSocket, OSGi, JMX, JNDI, JAAS and Many other integrations. These components is open source and available for commercial use and distribution.

Jetty is used in a wide variety of projects and products, both in development and production. Jetty can easily embedded in devices, tools, frameworks, application servers, and clusters. See the Jetty Powered page For more uses of Jetty.

The current recommended version of the Jetty 9 which can be obtained Here:jetty Downloads. Also available is the latest maintenance releases of Jetty 8 and Jetty 7.

The Jetty project has been hosted at the Eclipse Foundation since 2009. Prior releases of Jetty has existed in part or completely under the Jetty project at the Codehaus and Sourceforge before that. See the on page for more information on the history of Jetty.

2) Start jetty

3) Understand the difference between jetty_base and Jetty_home

4) Deploy Test.war

5) Install the plugin

Second: Tomorrow's plan

1) Take care of the plug-in deployment directly to jetty

2) Take care of plug-ins deployed directly to Tomcat

3) Find out about JBoss and jetty connections.

Three: Difficult problems

1) If you start the project with jetty in Eclipse, is it only possible to start with the jetty server adapter or Run-jetty-run plugin and not use the local jetty? After that deployment to the production environment how to ensure that the project can be run in the production environment jetty?

2) What is the role of the jetty plugin configured in Maven's Pom.xml? Development environment can be started with run-jetty-run, production environment can be put into the webapp, when the jetty plug-in use?

3) Online said in the project directory with MVN Jetty:run start, if the production environment, but also to install Maven?

4) Execute this start command mvn where did Jetty:run,jetty come from?

<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.5.v20130815</version>

Four: Thinking Summary

I see the jetty principle and the framework of the knowledge now the slightest use, or wait to meet the detailed study it

jetty9.1 later appeared jetty.base this concept, refers to your WebApps directory is the path (of course, this WebApps directory can also be modified, but most of the applications are directly using this webapps), in a few cases explained:

1, download down jetty direct use, that is, your war file directly in the Extract directory WebApps, and then through Java-jar Start.jar start, at this time the Jetty.base and Jetty.home are the current directory, can be through Java- Jar Start.jar--list-config to view the following:

2, see that Demo-base folder (Jetty version is 9.0 later), this folder is jetty used to do jetty.base case, go to see, directory structure such as:

Demo-base contains all the files that can start a web app. In other words, using the files in this directory can also start jetty, how to start, enter Demo-base, and then Java-jar. /start.jar to start, again using--list-config to view, only a few content, and the source of the content is demo-base, including Jetty.base and Jett.home, see it, not the same, Jetty.base is the current directory:

That is, you can create a directory as Jetty.base, and then place the war package in that directory to start the required jetty configuration file.

3, in the system of any directory to create a folder, as Jetty.base use (in fact, as in the 2nd case, start by specifying the Start.jar can be started)

There are a few more points to note:

1, jetty.home default is the directory where Start.jar

2, you can specify the Jetty.base directory by following the Jetty.base Java-jar Start.jar:

Java-jar Start.jar jetty.base= ...

3, Jetty.home is actually the jetty default configuration file, the default module definition directory, Jetty.base is for a WebApp customization of a configuration file directory

--list-modules: This command returns all available modules for the current service, and also shows the local modules, including the order in which the modules are implemented, the dependent modules, and the corresponding jar information

--list-config: Displays information such as the running environment and configuration files

In Jetty9, only the configuration files under the jetty base path are edited, and the properties are modified

1, the structure of the Web application:

Before we say jetty deployment, let's talk about the structure of the Web application defined by the servlet specification, which should be familiar, here's a list:

web-inf/

web-inf/lib/

web-inf/classes/

Web-inf/web.xml

The above content is a webapp must have, where at startup Jetty WebappClassLoader will first load the class file from the classes, and then load the class file in the go to Lib directory

2. How to Deploy

Jetty supports multiple deployment methods, such as a war package that satisfies the above conditions in the servlet specification, jetty the XML deployment descriptor provided by itself, or simply a folder that satisfies the servlet specification (the war package would have been decompressed)

(1) Simple deployment, directly put the war package or the extracted war directory into the Jetty.home/webapps directory, and then start, jetty deployment scanner will find the content of the deployment, The ContextPath is then automatically set to the name of the war package or war directory to complete the deployment, but pay attention to the name of the war, When the name of the war is Root.war or the name of the folder is War, ContextPath is root, and when accessed in the browser, it is not necessary to enter ContextPath, but to access the root directory directly, such as http://localhost : 8080/You can access to Root.war this app, when your jetty only need to deploy this app, name it Root.war or drip.

What happens when you need to make the war package different in name and ContextPath? Is the second way:

(2) The XML deployment descriptor, which means that no war package or war directory other than the XML file descriptor is placed in the WebApps directory, the jetty deployment scanner can automatically load into this XML file, You can then find your war package or war directory using the war and ContextPath attributes in the Webappcontext instance defined in the XML file, such as an XML file:

<configure class= "Org.eclipse.jetty.webapp.WebAppContext" >

<set name= "ContextPath" >/mycontext</Set>

<set name= "war" >/home/wilsonp/myapp/myapp.war</Set>

</Configure>

Jetty parses the XML file and then automatically searches to the Myapp.war file and defines its contextpath as/mycontext, which can be entered directly after it is launched http://localhost:8080/mycontext/ will be able to access the application.

There are other properties in Webappcontext:

Extractwar:

<configure class= "Org.eclipse.jetty.webapp.WebAppContext" >

<set name= "ContextPath" >/mycontext</Set>

<set name= "war" >/home/wilsonp/myapp/myapp.war</Set>

<set name= "Extractwar" >false</Set>

</Configure>

With the above settings, you can deploy Myapp.war without having to expand the war file.

Remember that you can set the application initialization parameters in the Web. xml file? In fact, it can be set here, the following settings,

<configure class= "Org.eclipse.jetty.webapp.WebAppContext" >

<set name= "ContextPath" >/mycontext</Set>

<set name= "war" >/home/wilsonp/myapp/myapp.war</Set>

<set name= "Extractwar" >false</Set>

<get name= "ServletContext" >

<call name= "Setinitparameter" >

<Arg>myapp.config</Arg>

<Arg>/home/wilsonp/myapp/config/app-config.xml</Arg>

</Call>

</Get>

</Configure>

You can set the ServletContext parameter when starting jetty, the parameter can be an XML file, jetty will parse it automatically, but note that jetty resolves the deployment descriptor file before parsing the Web. XML, which is overwritten if the Web. XML also has parameters with the same name in the App-config.xml.

Overridedescriptor:

Look at the following configuration:

<configure class= "Org.eclipse.jetty.webapp.WebAppContext" >

<set name= "ContextPath" >/mycontext</Set>

<set name= "war" >/home/wilsonp/myapp/myapp.war</Set>

<set name= "Extractwar" >false</Set>

<get name= "ServletContext" >

<call name= "Setinitparameter" >

<Arg>myapp.config</Arg>

<Arg>/home/wilsonp/myapp/config/app-config.xml</Arg>

</Call>

</Get>

<set name= "Overridedescriptor" >/home/wilsonp/myapp/config/overlay-web.xml</Set>

</Configure>

Jetty parsing the Web. xml file will parse the Overlay-web.xml file, that is, you can overwrite the attributes in the Web. XML, or add some additional properties, lest the Web. xml file be changed to change, trouble, with this attribute is easy.

Jetty can also configure the Jndi data source, go to see it yourself!

(3) The second way is to place the war package, you can actually place any directory that satisfies the servlet specification can be

(4) and the last one is in the Jetty9 series of Jetty.home and Jetty.base said Jetty.base way

No, I know. In these ways, in fact I have been using the second way, simple and convenient, but also easy to modify

Jetty;linux directory Structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.