Thursday, January 9, 2014

Tomcat 7 FindClass org/apache/catalina/startup/Bootstrap failed


  • Windows Server 2008 R2
  • Tomcat 7 x64
  • jdk1.7.0_45 x64


After upgrading from Tomcat 6 to 7 the new Tomcat instance did not want to start up. This is what I saw in the logs:

[2014-01-09 19:08:46] [info]  [ 2516] Commons Daemon procrun ( 64-bit) started
[2014-01-09 19:08:46] [info]  [ 2516] Running 'Tomcat7' Service...
[2014-01-09 19:08:46] [info]  [ 6004] Starting service...
[2014-01-09 19:08:47] [error] [ 6080] FindClass org/apache/catalina/startup/Bootstrap failed
[2014-01-09 19:08:47] [error] [ 6004] Failed to start Java
[2014-01-09 19:08:47] [error] [ 6004] ServiceStart returned 4
[2014-01-09 19:08:47] [info]  [ 2516] Run service finished.
[2014-01-09 19:08:47] [info]  [ 2516] Commons Daemon procrun finished

2014-01-09 19:08:46 Commons Daemon procrun stderr initialized
java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
    at org.apache.catalina.startup.Bootstrap.(
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    ... 1 more
Exception in thread "main" 

All I found on the net was that Java 5 is not compatible with Tomcat 7. But I had the latest Java 7.


With trial and error I found the solution:

I had to include tomcat-juli.jar also in the Java Classpath!

I opened an administrative Command Prompt and edited the Tomcat instance's Properties

D:\apps\tomcat7\bin> tomcat7w.exe //ES//Tomcat7

Monday, January 6, 2014

Compress Old Files with PowerShell

The Story

The following PowerShell script will compress files that are older than the specified amount of time. It is handy for archiving IIS Logs, SQL Backups, etc.
The script uses 7-zip so you obviously have to have it installed (or the exe copied somewhere). It's using maximum compression which is resource intensive, if you don't want that just remove the "-mx9 -m0=lzma2" parameters.

The Script

$path = "C:\inetpub\logs\LogFiles\"
$mask = "*.log"

$days = 7

$files = dir $path -Recurse -Include $mask | where {($_.LastWriteTime -lt (Get-Date).AddDays(-$days).AddHours(-$hours).AddMinutes(-$mins)) -and ($_.psIsContainer -eq $false)}

ForEach ($file in $files) {

    & "C:\Program Files\7-Zip\7z.exe" u -mx9 -t7z -m0=lzma2 ($file.FullName + ".7z") $file.FullName
    if ($LASTEXITCODE -eq 0) {
        Remove-Item $file