I have installed jetty 9 but I fail to start/stop it as a service. Running from command line works.
root@backend:/opt/jetty# service jetty start
Job for jetty.service failed. See 'systemctl status jetty.service' and 'journalctl -xn' for details.
root@oakstair-backend:/opt/jetty# systemctl status jetty.service
● jetty.service - LSB: Jetty start script.
Loaded: loaded (/etc/init.d/jetty)
Active: failed (Result: exit-code) since Fri 2016-12-16 10:14:47 UTC; 6min ago
Process: 11826 ExecStart=/etc/init.d/jetty start (code=exited, status=1/FAILURE)
Dec 16 10:14:43 backend jetty[11826]: JETTY_PID = /var/run/jetty.pid
Dec 16 10:14:43 backend jetty[11826]: JETTY_START = /opt/jetty/start.jar
Dec 16 10:14:43 backend jetty[11826]: JETTY_ARGS = --add-to-start=console-capture jetty.state=/opt/jetty/jetty.state jetty-logging.xml jetty-started.xml
Dec 16 10:14:43 backend jetty[11826]: JAVA_OPTIONS = -Dorg.eclipse.jetty.LEVEL=DEBUG -Djetty.logging.dir=/opt/jetty/logs -Djetty.home=/opt/jetty -Djetty.base=/opt/jetty -Djava.io.tmpdir=/tmp
Dec 16 10:14:43 backend jetty[11826]: JAVA = /usr/bin/java
Dec 16 10:14:43 backend jetty[11826]: RUN_CMD = /usr/bin/java -Dorg.eclipse.jetty.LEVEL=DEBUG -Djetty.logging.dir=/opt/jetty/logs -Djetty.home=/opt/jetty -Djetty.base=/opt/jetty -Djava.io.tmpdir=/tmp -jar /opt/jetty/start.jar --add-to-st...ml jetty-started.xml
Dec 16 10:14:47 backend jetty[11826]: Starting Jetty: FAILED Fri Dec 16 10:14:47 UTC 2016
Dec 16 10:14:47 backend systemd[1]: jetty.service: control process exited, code=exited status=1
Dec 16 10:14:47 backend systemd[1]: Failed to start LSB: Jetty start script..
Dec 16 10:14:47 backend systemd[1]: Unit jetty.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
root@backend:/opt/jetty#
root@backend:/opt/jetty# ls /var/log/jetty/
root@backend:/opt/jetty#
Currently using jetty 9.3.14 since i first tried 9.4.0 with same result.
Can't say that jetty is very helpful in telling why it does not want to start as a service. Found some other guy with same problem that had to do with file/dir owner. But I have checked that.
Oops I found that it logs to /opt/jetty/logs instead of /var/logs/jetty as I wanted. So now I have some more info ...
StartLog Establishing /opt/jetty/logs/start.log on Fri Dec 16 13:40:16 UTC 2016
org.eclipse.jetty.start.graph.GraphException: Missing referenced dependency: console-capture
at org.eclipse.jetty.start.graph.Graph.selectNodes(Graph.java:470)
at org.eclipse.jetty.start.BaseBuilder.build(BaseBuilder.java:152)
at org.eclipse.jetty.start.Main.start(Main.java:407)
at org.eclipse.jetty.start.Main.main(Main.java:75)
-Djetty.home=/opt/jetty -Djetty.base=/opt/jetty
Do not use the same directory for jetty.home
and jetty.base
.
As the documentation, and the startup warnings (since Jetty 9.2.0) tell you.
General suggestions (you'll be happy when you do this, and it all starts to make sense):
Unpack a fresh distribution of jetty-home
(or the older jetty-distribution
tarball) into a empty ${jetty.home}
directory.
Leave the
${jetty.home}
directory alone, don't edit it, don't rename things, don't delete things, don't add things, don't change anything in it.
Setup a proper ${jetty.base}
directory somewhere, make sure it does not overlap with your ${jetty.home}
directory in any way.
Now configure your instance of jetty entirely within your ${jetty.base}
directory.
Example:
# Initialize a fresh base directory (only need to do this once, ever)
$ mkdir /path/to/mybase
$ cd /path/to/mybase
# Prepare the jetty.base directory (this just creates directories, and adds start.d/*.ini for you)
$ java -jar /path/to/jetty-dist/start.jar --add-to-start=http,deploy,resources,ext,jmx,requestlog,console-capture,annotations,jsp
MKDIR : ${jetty.base}/start.d
INFO : webapp transitively enabled, ini template available with --add-to-start=webapp
INFO : ext initialized in ${jetty.base}/start.d/ext.ini
INFO : server transitively enabled, ini template available with --add-to-start=server
INFO : requestlog initialized in ${jetty.base}/start.d/requestlog.ini
INFO : servlet transitively enabled
INFO : jsp initialized in ${jetty.base}/start.d/jsp.ini
INFO : resources initialized in ${jetty.base}/start.d/resources.ini
INFO : annotations initialized in ${jetty.base}/start.d/annotations.ini
INFO : plus transitively enabled
INFO : deploy initialized in ${jetty.base}/start.d/deploy.ini
INFO : security transitively enabled
INFO : jmx initialized in ${jetty.base}/start.d/jmx.ini
INFO : apache-jsp transitively enabled
INFO : console-capture initialized in ${jetty.base}/start.d/console-capture.ini
INFO : jndi transitively enabled
INFO : http initialized in ${jetty.base}/start.d/http.ini
MKDIR : ${jetty.base}/lib
MKDIR : ${jetty.base}/lib/ext
MKDIR : ${jetty.base}/logs
MKDIR : ${jetty.base}/resources
MKDIR : ${jetty.base}/webapps
INFO : Base directory was modified
$ ls -F
lib/ logs/ resources/ start.d/ webapps/
# Configure your jetty.base instance
$ cp /tmp/mywebapp.war webapps/
$ edit start.d/http.ini
# Start your server instance (manually)
$ java -jar /path/to/jetty-dist/start.jar
Since you are starting via a service ...
The startup script, found in ${jetty.home}/bin/jetty.sh
needs to go into your appropriate /etc/
directory (too many options to list them out here).
And you'll configure your JETTY_HOME
and JETTY_BASE
directories in your usual /etc/default/jetty
file.
In the future, when a new version of Jetty is released ...
/opt/jetty-dist-9.5.0
/etc/default/jetty
and set the JETTY_HOME=/opt/jetty-dist-9.5.0
You don't have to edit your ${jetty.base}
to do an upgrade.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With