When I try to “invoke local” a Java 11 project I get a UnsupportedClassVersionError. I think the docker container that is used by serverless doesn’t ship with the correct java version. But how can I upgrade it?
$ npx sls invoke local --function create --stage dev-babowe
Serverless: serverless-certificate-creator version 1.3.0 called
Serverless: In order to get human-readable output, please implement "toString()" method of your "ApiGatewayResponse" object.
Exception in thread "main"
java.lang.UnsupportedClassVersionError: com/foobar/Handler has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.serverless.InvokeBridge.getInstance(InvokeBridge.java:70)
at com.serverless.InvokeBridge.<init>(InvokeBridge.java:37)
at com.serverless.InvokeBridge.main(InvokeBridge.java:151)
$ npx sls --version
Serverless: serverless-certificate-creator version 1.3.0 called
Framework Core: 1.76.1
Plugin: 3.6.17
SDK: 2.3.1
Components: 2.33.0