dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.16k stars 794 forks source link

Support for Java 17 #1710

Closed mauripardo closed 10 months ago

mauripardo commented 1 year ago

Hi I am using serverless-offline version v12.0.4, today the java supported version are 'java8', 'java8.al2', 'java11'. I want to know if you can add support to java 17. This framework is awesome! I hope you can work in this request.

Thanks

dnalborczyk commented 10 months ago

support has been added in: https://github.com/dherault/serverless-offline/releases/tag/v13.0.0

randomf commented 7 months ago

Hi @dnalborczyk ,

support has been added, but is dysfunctional. Technically serverless-offline allows you to specify java17 as runtime, but

1) serverless-offline depends on serverless-toolkit (4 years unmaintained package), where java-invoke-local / serverless.jvm.plugin depends on Groovy 2.5.9, which is incompatible with Java 17. First version to be compatible with Java 17 is Groovy 3.0.8. You get following error when running serverless offline

OpenJDK 64-Bit Server VM warning: Ignoring option --illegal-access=deny; support was removed in 17.0
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
    at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
    at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
    at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:107)
    at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:95)
    at org.codehaus.groovy.reflection.ReflectionCache.<clinit>(ReflectionCache.java:39)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:210)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:108)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:86)
    at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
    at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:180)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.isCase(ScriptBytecodeAdapter.java:679)
    at serverless.jvm.plugin.MainCli.main(MainCli.groovy:38)
Caused by: java.lang.ExceptionInInitializerError: Exception org.codehaus.groovy.GroovyBugError [in thread "main"]
    at org.codehaus.groovy.vmplugin.v7.Java7.<clinit>(Java7.java:45)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at org.codehaus.groovy.vmplugin.VMPluginFactory.createPlugin(VMPluginFactory.java:57)
    at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:39)
    ... 12 more
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
    at org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod.<clinit>(NumberNumberMetaMethod.java:33)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.createMetaMethodFromClass(MetaClassRegistryImpl.java:258)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:111)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:86)
    at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
    at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:180)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.isCase(ScriptBytecodeAdapter.java:679)
    at serverless.jvm.plugin.MainCli.main(MainCli.groovy:38)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 [in thread "main"]
    at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
    at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
    at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:107)
    at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:95)
    at org.codehaus.groovy.reflection.ReflectionCache.<clinit>(ReflectionCache.java:39)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:210)
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:108)
    ... 6 more

2) When setting useDocker directive to true, an error for missing Docker image lambci/lambda:java17 is thrown: No valid trust data for java17. There is no reasonable expectation for image to be added, since serverless-offline relies on a deprecated project lambci/docker-lambda

I think this ticket should be re-opened.

Thank you

Sandro-Intelcom commented 7 months ago

Hello @dnalborczyk,

I'm having the exact same issues described by @randomf. It appears support for Java 17 is not functional at this time.

AndrewWoodwardTCH commented 7 months ago

+1 to reopen this as I am also getting the same issue as above. This is also going to remain an issue while teams are updating to Java 17 and eventually Java 21.

philippeCM-Intelcom commented 7 months ago

+1 to reopen, I am getting the same issue

valtechtmn commented 6 months ago

+1 to reopen, I can't use java 11 for another unrelated issue and was trying to migrate to java 17 but then I'm faced with the issue @randomf described, please @dnalborczyk take a look this is quite crippling !

enricocavallin-crispybacon commented 5 months ago

+1 to reopen, I am getting the same issue

SuperCaliMan commented 4 months ago

Same issue as @randomf, any update?

rbpimenta commented 3 months ago

+1 for reopen this. Using runtime java17 gives me the same error