Wednesday 17 October 2012

Apache Tomcat HTTP Status 500 - javax.servlet.ServletException: java.lang.UnsupportedClassVersionError


HTTP Status 500 - javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: com/namespace/project/class : Unsupported major.minor version 51.0 (unable to load class com.namespace.project.class)


If you've seen an error like this when trying to run a Tomcat project, the problem is that the JAVA version used to compile the class mentioned in the error is different than the JAVA version Tomcat uses. You can either recompile the class or change the JAVA version Tomcat uses.

To change the settings for Tomcat, in Windows, modify the catalina.bat file by adding the following line in red. You most probably have a different location for your JDK. This version is the version used for compiling the class that gives the error. After adding the line remember to restart Tomcat (shutdown.bat and startup.bat) if it is already running.

rem set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%]
rem
rem $Id: catalina.bat 1344732 2012-05-31 14:08:02Z kkolinko $
rem -----------------------------------------------------------

set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_33

rem Suppress Terminate batch job on CTRL+C
if not ""%1"" == ""run"" goto mainEntry
if "%TEMP%" == "" goto mainEntry
if exist "%TEMP%\%~nx0.run" goto mainEntry

No comments:

Post a Comment