Nick's Tech Blog: Installing Tomcat8 as a service on Window7

Pages

Tuesday, December 24, 2013

Installing Tomcat8 as a service on Window7

Install it!

  1. Download Tomcat8 zip for your operating system. -> http://tomcat.apache.org/download-80.cgi (I grabbed the Windows 64bit version)
  2. Unzip it to the directory where you want it to live.

Check your Config

  1. Check your config by running <tomcat_home>\bin\configtest.bat

Error1: JVM & JDK had a space in the name.
Fix1: Fixed by setting JAVA_HOME and JRE_HOME Environment Variables to use C:\Progra~1\Java\<java_version>

Error2: JVM was 32bit, needed to be 64bit
Fix2: Changed JAVA_HOME and JRE_HOME to use correct 64bit Java install. 

Install Tomcat8 as a service

  1. Run: <tomcat_home>\bin\service.bat install
When starting, it failed with "Error Code 4".
I had a look in the Windows System Logs, and found this: "The Tomcat8 service terminated with service-specific error The system cannot open the file."

Enable logging:

  1. Run <tomcat_home>\bin\tomcat8w.exe (a window will open)
  2. Under the "Logging" tab, set the logging directory
  3. Set the STDOUT and STDERR files
  4. Set the logging to DEBUG (turn this back to INFO when app starts up successfully).
  5. Attempt to start the app again, and check the logs:

Error3: stderr.log
2013-12-24 13:18:43 Commons Daemon procrun stderr initialized
java.lang.NoClassDefFoundError: org/apache/catalina/startup/Bootstrap
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.startup.Bootstrap
Fix3: Using tomcat8w.exe
  1. Run <tomcat_home>\bin\tomcat8w.exe (a window will open)
  2. Under the "Java" tab, set the classpath (which was empty) to the following:
C:\devtools\apache-tomcat-8.0.0-RC5\lib\*;C:\devtools\apache-tomcat-8.0.0-RC5\bin\*;

After that, I was able to start up Tomcat8 successfully -> http://localhost:8080/

After installing some apps, I got:
Error4: java.lang.OutOfMemoryError: PermGen space
Fix4: 
  1. Run <tomcat_home>\bin\tomcat8w.exe (a window will open)
  2. Under the "Java" tab, I changed the "Java Options" to:
-Dcatalina.base=C:\devtools\apache-tomcat-8.0.0-RC5
-Dcatalina.home=C:\devtools\apache-tomcat-8.0.0-RC5
-Djava.endorsed.dirs=C:\devtools\apache-tomcat-8.0.0-RC5\endorsed
-Djava.io.tmpdir=C:\devtools\apache-tomcat-8.0.0-RC5\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\devtools\apache-tomcat-8.0.0-RC5\conf\logging.properties
-Xms256M
-Xmx1024M
-XX:MaxPermSize=1024M
-XX:MaxHeapSize=256M
-XX:PermSize=256M
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled

Everthing's now working smoothly!

Additional Notes:

1) I had to add <tomcat_home>/bin/tomcat7.exe and <tomcat_home>/bin/tomcat7w.exe to Windows Firewall.

2) When uploading a new application, I got the following error:
java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (53706238) exceeds the configured maximum (52428800)
Simply modify the following section in <tomcat_home>/webapps/manager/WEB-INF/web.xml
    <multipart-config>
      <!-- 50MB max -->
      <max-file-size>52428800</max-file-size>
      <max-request-size>52428800</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>

I doubled the values from 52428800 to 104857600.

1 comment:

  1. nice blog, it helped me startup tomcat8 on windows7.... thumbs up.

    ReplyDelete