gregs

jetty

Configuring Jetty’s memory usage

by gregs on Apr.20, 2010, under *nix, debian, jetty

Debian specific, but if you need to edit jvm configuration details for Jetty, look for this file:

CODE:
  1. /etc/default/jetty

And locate the lines below to start fine tuning Jetty's memory usage:

CODE:
  1. # Extra options to pass to the JVM         
  2. JAVA_OPTIONS="-Xmx256m -Djava.awt.headless=true"

Leave a Comment more...

Deploying grails webapp to Jetty – resolving a few issues…

by gregs on Mar.23, 2010, under grails, jetty

So you have deployed your app and can access the start page of your grails app. If you are like me deploying your app to a Debian\Jetty type of configuration you might come across the following error:

CODE:
  1. java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config

When trying to access a controller from the default start page. I traced this to a missing dependency in grails (I use SpringSource Tool Suite for development so that maybe the root cause). By opening and editing your /project/grails-app/conf/(default package)/BuildConfig.groovy, add the following under grails.project.dependency.resolution.

CODE:
  1. grails.project.dependency.resolution = {
  2.     ...
  3.     dependencies {
  4.         // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
  5.     runtime "javax.servlet:jstl:1.1.2"
  6.         // runtime 'mysql:mysql-connector-java:5.1.5'
  7.     }
  8. }

Build your war and re-deploy. Still getting an error?? I was. For jetty there was still an issue with calling the controller. After spending some time exploring, it looks like Jetty support was removed from Grails 1.2. I stumbled across a post mentioning installing the grails Jetty plugin with:

CODE:
  1. . grails install-plugin jetty

After running this, and re-building my war file and re-deploying it one final time, bingo it all worked.

Leave a Comment more...

Deploying grails app to Jetty

by gregs on Mar.20, 2010, under *nix, apache, debian, grails, jetty

Short and sweet, step by step guide for creating a grails war and deploying it to your Jetty server (includes apache2 proxy steps)

  1. grails war (your app), in this case epic.war
  2. Copy to server
    CODE:
    1. scp epic.war user@server:/location

  3. On Debian the location for jetty webapps is: /var/lib/jetty/webapps
  4. Copy from upload location to the above folder (I used sudo)
  5. Change permissions:
    CODE:
    1. sudo chown jetty:adm epic-0-0.1.war

  6. created a *.xml context file in /etc/jetty/contexts, with something like this [note case is important!!]:
    CODE:
    1. <?xml version="1.0"  encoding="ISO-8859-1"?>
    2. <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
    3. <Configure class="org.mortbay.jetty.webapp.WebAppContext">
    4.   <Set name="contextPath">/epic</Set>
    5.   <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/epic-0-0.1.war</Set>
    6. </Configure>

  7. restart jetty :
    CODE:
    1. sudo /etc/init.d/jetty restart

    (try stop/start as well)

  8. test with :
    CODE:
    1. lynx http://localhost:8080/epic/

  9. Nice but I'd like http://localhost/epic/ so enable mod_proxy in apache if you haven't already :
    CODE:
    1. a2enmod proxy

  10. edit /etc/apache2/mods-enabled/proxy.load and if not present add at end:
    CODE:
    1. LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

  11. edit your virtualhost conf file I am using 000-default and add:
    CODE:
    1. ProxyRequests Off
    2. <Proxy *>
    3.     Order deny,allow
    4.      Allow from all
    5. </Proxy>
    6. ProxyPass        /epic http://localhost:8080/epic
    7. ProxyPassReverse /epic http://localhost:8080/epic
    8. ProxyPreserveHost On

  12. restart apache : 
    CODE:
    1. sudo /etc/init.d/apache2 restart

  13. now you can
    CODE:
    1. lynx http://localhost/epic/

Update: I had omitted the ProxyPreserveHost On from the Apache configuration, which resulted in css, images and external javascripts not loading. It also caused an issue with accessing controllers.

Sources:

1 Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!