Tuesday, September 15, 2009

Tip: Enabling JSP support in Jetty.7.0.0

Jetty7, doesn't enable jsp support by default, so after one hour trying to understand what was happening, I got the reason.

If you get jetty from eclipse's site, it doesn't come with the needed jsp libraries, so you have to put these libraries manually or download jetty with jsp libraries from codehaus.

But, this is not enough, if you start the server you get an error like this:
INFO::NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet

So you have to enable jsp support in jetty passing additional undocumented options to the jetty start script:
$ java -jar jetty.jar OPTIONS=Server,jsp

The best option to start jetty and customize it is using the provided script: bin/jetty.sh. But you have to do these steps:

# change the permissions of the provided script.
 $ chmod u+x bin/jetty.sh

 # create a file where you can put customized options.
 $ cat /etc/default/jetty
JAVA_OPTIONS="$JAVA_OPTIONS -Dartifactory.home=/mirai/DATA/artifactory"
 # create the link in /etc/init.d
 $ sudo ln -s /usr/local/jetty/bin/jetty.sh /etc/init.d/jetty

 # use this script to start/stop/restart the server
 $ /etc/init.d/jetty <start|stop|restart>