Wednesday, March 24, 2010

Tomcat survival kit (Tomcat6)


  • Servlet container, no EJB support

  • /conf
    Ubuntu: /var/lib/tomcat6/conf
    W7: C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0
    /usr/share/tomcat/bin/catalina.sh

  • To see access log on your Tomcat, add the following to your conf/server.xml :

    &lt Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common"/ &gt

  • to administer the modules
    http://localhost:8080/manager/html
    default user: "admin / no pw"
    Otherwise, you can add
    &lt user name="username" password="secret" roles="standard,manager" / &gt
    in /Tomcat 6.0/conf/tomcat-users.xml

  • default location for war files
    /var/lib/tomcat6/webapps
    then you do: http://192.168.0.12:8082/sample/

  • for security reasons, slashes cannot be url encoded, like:
    http://127.0.0.1:8080/getimagelist/http%3A%2F%2F
    ( %3A works but not %2F). See property
    org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH: true|false

  • for memory setting like

    JAVA_OPTS="-Djava.awt.headless=true -server -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"

  • to make sure you don't use openJDK
    edit /etc/init.d/tomcat6 and look for JDK_DIRS

  • if JAVA_HOME is not found when doing sudo /etc/init.d/tomcat start, do:
    sudo -E /etc/init.d/tomcat start

  • other things:
    ./usr/share/tomcat6/bin/catalina.sh
    /var/lib/tomcat6/conf/logging.properties
  • "too many open files" in catalina
    • ulimit -a
      • pipe size (512 bytes, -p) 8
    .
  •