private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
To start Jetty on the default port of 8080, run the following command:
> java -jar start.jar
You should see about twenty lines of logged INFO statements similar to the following, informing you of the components being started:
2012-10-22 16:02:24.988:INFO:oejs.Server:main: jetty-9.0.0-M2 2012-10-22 16:02:25.040:INFO:oejs.NCSARequestLog:main: Opened /home/gregw/src/jetty-9/jetty-distribution/target/distribution/logs/2012_10_22.request.log 2012-10-22 16:02:25.115:INFO:oejs.ServerConnector:main: Started ServerConnector@6aeeafb{HTTP/1.1}{0.0.0.0:8080} 2012-10-22 16:02:25.348:INFO:oejs.ServerConnector:main: Started ServerConnector@24a45e{SSL-http/1.1}{0.0.0.0:8443} 2012-10-22 16:02:25.357:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:/home/gregw/src/jetty-9/jetty-distribution/target/distribution/webapps/] at interval 1 2012-10-22 16:02:25.688:INFO:oejd.DeploymentManager:main: Deployable added:/home/gregw/src/jetty-9/jetty-distribution/target/distribution/webapps/test.xml 2012-10-22 16:02:25.725:INFO:oejw.WebInfConfiguration:main: Extract jar:file:/home/gregw/src/jetty-9/jetty-distribution/target/distribution/webapps/test.war!/ to /tmp/jetty-0.0.0.0-8080-test.war-_test-any-/webapp 2012-10-22 16:02:26.097:INFO:oejsh.ContextHandler:main: started o.e.j.w.WebAppContext@4e3ceb07{/test,file:/tmp/jetty-0.0.0.0-8080-test.war-_test-any-/webapp/,AVAILABLE}{/test.war}
You also see some warnings like:
2012-10-22 16:02:24.748:WARN::main: test-realm is deployed. DO NOT USE IN PRODUCTION! 2012-10-22 16:02:25.582:WARN::main: async-rest webapp is deployed. DO NOT USE IN PRODUCTION!
These warnings are telling you that some demonstration web applications and services are deployed and that you should remove them before putting the server into production. You can ignore these warnings while testing, or you can see Deploying Web Applications to learn how to remove them.
After starting Jetty, you can test it by pointing a browser or any HTTP client at port 8080 of the machine. If
you are running the browser on the same machine as the Jetty instance, the URL to use is:
http://localhost:8080/
and your browser or HTTP client should see the Jetty welcome page and be able to follow
the links to some test web applications.
If you see the following exception, you already have something running on the port that Jetty is configured to run on and you either need to shut down whatever that process is, or configure Jetty to run on another port.
java.net.BindException: Address already in use at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:344) at sun.nio.ch.Net.bind(Net.java:336) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
You can configure Jetty to run on a different port by setting the jetty.port
Property on the
command line:
> java -jar start.jar jetty.port=8081
As alternatives, you can set this property in the start.ini
file or by editing the use
of the property in the etc/jetty-http.xml
configuration file. The way this works is that it
defines a property that is the etc/jetty-http.xml
configuration file uses to inject a port
value into the ServerConnector defined there. For more information see the
Quickstart Configuration Guide and Configuring
Connectors.
By values set in the start.ini
file, Jetty starts the HTTP connector that is defined in
etc/jetty-http.xml
. To also start the HTTPS connector defined in
etc/jetty-https.xml
you can simply append this configuration file to the command line:
> java -jar start.jar etc/jetty-https.xml
You can now test this connector by pointing your browser to:
https://localhost:8443/
Alternately, you can edit the start.ini
file and uncomment the line that includes the
HTTPS configuration file and then start Jetty without any extra command line arguments. Note that you can also
change the SSL port with the jetty.tls.port
Property:
> java -jar start.jar jetty.tls.port=8444 etc/jetty-https.xml
The job of the start.jar
command is to interpret the command line and
start.ini
arguments in order to build a java classpath and list of properties and configuration files to
pass to the main class of the Jetty XML configuration mechanism. The start.jar
mechanism has many
options which are documented in Chapter 16, Starting Jetty; you can see them in summary by using the
command:
> java -jar start.jar --help
If you have started Jetty from the command line, it is safe to stop it using the normal Ctrl-C key sequence to abort it. This triggers an orderly shutdown of the server.
However, you might have started the server with some advanced start.jar
options so that it runs
in the background:
> java -jar start.jar -DSTOP.PORT=8881 -DSTOP.KEY=magic --daemon &
You should shut down this server with the command:
> java -jar start.jar -DSTOP.PORT=8881 -DSTOP.KEY=magic --stop
See an error or something missing? Contribute to this documentation at Github!