Tomcat Web Server

From Kb

Jump to: navigation, search

Contact Article Author | Blog of Article Author | FirstPartners.net Home | LinkedIn profile of Author

Contents

See Also

First steps

  • Install Java
  • Install Tomcat
    • Use default port 8080 and default username / password (admin / blank)
    • If these change , search for the relevant entries in the pom.xml and change to match

Command Line - stop and start Tomcat (on Windows)

  • net stop "apache tomcat"
  • net start "apache tomcat"

Deploying to Tomcat Manually

  1. Build war using mvn package
  2. Ensure Tomcat is running
  3. Go to http://localhost:8080
  4. Open the Manager application (normally at http://localhost:8080/manager)
  5. Use the web interface to deploy

Deploying to Tomcat with Maven

Most commonly used

  • mvn war:exploded tomcat:deploy - 1st time
  • mvn war:exploded tomcat:redeploy - subsequent times

All of these are from the web directory of the project

Deploying to Tomcat with Cargo

Add information

Using Maven and Jetty

  • No Tomcat running
  • mvn jetty:run-war in the web section of your project

Out of Memory / Out of Heap Errors

Add the following variable: MAVEN_OPTS=-Xms256m -Xmx1024m -XX:PermSize=1024m -XX:MaxPermSize=1024m

Debugging Web Applications on Tomcat and Eclipse

  • Information from Tomcat Wiki , but if you have Tomcat installed as a windows service ...


  • In the Tomcat Manger (right click green play icon in windows system tray)
    • Open the Java Tab
    • In the Java options textbox
    • On separate lines , enter -Xdebug and -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n before the -D options.
    • Restart windows service
  • To Attach to process in Eclipse
    • Run ... Open Debug Dialog ... Remote Java application .. New Configuration
    • Localhost (or other) and the port number (8000) specified earlier
  • Add breakpoints in code, Eclipse Monitors code and switches to debug view when breakpoint encountered.

Running Tomcat Through Eclipse

  • Ensure you have the Web Tools Project installed
  • New configuration, add details of the local server
  • Run as Debug server , using pre build war file...
  • Add breakpoints in code, Eclipse Monitors code and switches to debug view when breakpoint encountered.
Personal tools