Issue
Contrast Java agent versions 4.x are no longer compatible with JVM versions prior to Java 8.
Cause
Contrast Java agent versions 4.x are compiled to classfiles with version 52, the version first released with the Java 8 JDK. When a JVM version prior to Java 8 attempts to launch an application including version 52 classfiles, it recognizes that the classfile format is a version that it does not understand and the application will shut down with an error similar to the following:
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/contrastsecurity/agent/ContrastLoaderAgent :
Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:300)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:397)
FATAL ERROR in native method: processing of -javaagent failed
Resolution
If such an error is encountered then either:
-
The JVM used to launch the application should be updated to at least Java 8
-
Contrast Java agent version 3.x should be used instead of the version 4.x agent.