Java – jetty.state issue when starting Jetty

javajetty

I rent a CentOS 6 VPS and wish to install Jetty on it so I can use Solr for a project I've been working on.

I've been following this jetty tutorial to install Jetty on my VPS, however when I try to start Jetty using service jetty start or /etc/init.d/jetty start I receive the following error(s):

Starting Jetty: grep: /var/run/jetty.state: No such file or directory
grep: /var/run/jetty.state: No such file or directory
grep: /var/run/jetty.state: No such file or directory
FAILED Sat Apr 20 00:21:56 BST 2013

I've looked in the logs and it doesn't look like anything is added to them regarding more information about this error. This is what my Jetty config file looks like:

JAVA_HOME=/usr/bin
JAVA=$JAVA_HOME/java
JAVA_OPTIONS=" -server -Xms256m -Xmx1024m -XX:+DisableExplicitGC "
JETTY_HOME=/srv/jetty
JETTY_USER=jetty
JETTY_PORT=7070
JETTY_HOST=localhost
JETTY_LOGS=/srv/jetty/logs/

Has anyone experienced this before and can point me in the right direction as to what I need to do to resolve it?

Best Answer

After hitting this problem, I found that jetty.state must be writable to the java process. So if you are not running jetty as root, /var/run will not be writable and you'll have this problem.

My solution is to create a directory where jetty can write, like /opt/jetty/run and put it into /etc/default/jetty file:

JETTY_RUN=/opt/jetty/run/