Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Spring Boot 3 support #487

Closed
garethpowell opened this issue Dec 1, 2022 · 17 comments
Closed

Provide Spring Boot 3 support #487

garethpowell opened this issue Dec 1, 2022 · 17 comments
Milestone

Comments

@garethpowell
Copy link

To help us debug your issue fill in the basic information below using the options provided

Serverless Java Container version: 1.9

Framework version: SpringBoot 3.0.0

Scenario

We would like to be able to use Spring Boot 3 in our Lambda development.

Expected behavior

To fully support Spring Boot 3

Actual behavior

Due to the javax to jakarta namespace/package change in JakartaEE and associated Spring Boot 3 use, the current aws-serverless-java-container does not startup.

Steps to reproduce

Deploy a Spring Boot 3 Lambda using the com.amazonaws.serverless:aws-serverless-java-container-springboot2:1.9 into AWS SAM local

Full log output

Paste the full log output from the Lambda function's CloudWatch logs

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    com.amazonaws.serverless.proxy.spring.embedded.ServerlessServletEmbeddedServerFactory.getWebServer(ServerlessServletEmbeddedServerFactory.java:44)

The following method did not exist:

    'void org.springframework.boot.web.servlet.ServletContextInitializer.onStartup(javax.servlet.ServletContext)'

The calling method's class, com.amazonaws.serverless.proxy.spring.embedded.ServerlessServletEmbeddedServerFactory, was loaded from the following location:

    jar:file:/var/task/lib/aws-serverless-java-container-springboot2-1.9.jar!/com/amazonaws/serverless/proxy/spring/embedded/ServerlessServletEmbeddedServerFactory.class

The called method's class, org.springframework.boot.web.servlet.ServletContextInitializer, is available from the following locations:

    jar:file:/var/task/lib/spring-boot-3.0.0.jar!/org/springframework/boot/web/servlet/ServletContextInitializer.class

The called method's class hierarchy was loaded from the following locations:

    org.springframework.boot.web.servlet.ServletContextInitializer: file:/var/task/lib/spring-boot-3.0.0.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes com.amazonaws.serverless.proxy.spring.embedded.ServerlessServletEmbeddedServerFactory and org.springframework.boot.web.servlet.ServletContextInitializer

Unable to start web server: org.springframework.context.ApplicationContextException
org.springframework.context.ApplicationContextException: Unable to start web server
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:164)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:578)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:150)
        at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.initialize(SpringBootLambdaContainerHandler.java:195)
        at com.amazonaws.serverless.proxy.InitializationWrapper.start(InitializationWrapper.java:35)
        at com.amazonaws.serverless.proxy.spring.SpringBootProxyHandlerBuilder.buildAndInitialize(SpringBootProxyHandlerBuilder.java:81)
        at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.getHttpApiV2ProxyHandler(SpringBootLambdaContainerHandler.java:110)
        at uk.co.mosaicisland.apihub.LambdaHandler.<init>(LambdaHandler.kt:24)
        at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
Caused by: java.lang.NoSuchMethodError: 'void org.springframework.boot.web.servlet.ServletContextInitializer.onStartup(javax.servlet.ServletContext)'
        at com.amazonaws.serverless.proxy.spring.embedded.ServerlessServletEmbeddedServerFactory.getWebServer(ServerlessServletEmbeddedServerFactory.java:44)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161)
        ... 14 more

Please note that in the short term, I've forked this project and migrated the code to support Spring Boot 3. It's far from optimal and some functionality is disabled or left unimplemented. It serves our needs for the moment, but we switch to an official Spring Boot 3 version when you have it ready.

@deki deki added this to the Release 2.0 milestone Dec 1, 2022
@deki
Copy link
Collaborator

deki commented Dec 1, 2022

Hi Gareth,
thanks for raising it. We are currently working on prioritizing this implementation. As it includes the move to Jakarta dependencies, all other modules besides Spring are affected as well.

@deki
Copy link
Collaborator

deki commented Dec 1, 2022

If you come across this issue and you'd like to see it implemented, please +1 here or reach out privately to me or your AWS account team. The more customers requesting it, the easier it is for us to prioritize it.

@deki
Copy link
Collaborator

deki commented Dec 12, 2022

If you are looking to run Spring Boot 3 on Lambda before we finish the work on this issue, this sample may be helpful for you: https://github.com/maschnetwork/aws-lambda-spring-boot-3

@garethpowell
Copy link
Author

If you are looking to run Spring Boot 3 on Lambda before we finish the work on this issue, this sample may be helpful for you: https://github.com/maschnetwork/aws-lambda-spring-boot-3

Thanks for this. I do have a Spring Boot 3 Lambda deployment working, but will review this and see if it can be improved based on the sample you've supplied.

@tntsoft
Copy link

tntsoft commented Jan 2, 2023

@garethpowell Can you kindly share a repo containing a demo of how you achieved this? I'm actively looking to convert at least a few parts of my Spring Boot 3 app to serverless. Thanks in advance!

@bajajyog
Copy link

bajajyog commented Jan 8, 2023

We need Spring boot 3 support for AWS Java serverless container library and please advise how soon this will be available

@markthoelen
Copy link

+1

@Artur-
Copy link
Contributor

Artur- commented Feb 3, 2023

This would be nice for several reasons ranging from "You should not start new apps on Spring Boot 2 as it reasonably soon reaches end of life" to "Spring Boot 3 has support for native compilation which combined with lambda could be super great"

@helloworld121
Copy link

Hi, I am also waiting for SpringBoot3 support. Looking forward to it :)

@fsomme2s
Copy link

+999

Any way for the humble spring developer to support this other than upvoting?

@deki
Copy link
Collaborator

deki commented Feb 13, 2023

Appreciate your interest. If you know your AWS account team, please talk to them about it to make sure they influence the related feature requests internally for you. We are actively working on additional support for this project.

Of course pull requests are welcome as well. Another contributor already started working on #478 with a focus on Jersey but Jakarta EE is a prerequisite for Spring Boot 3 too.

In addition Spring Boot 3 requires Java 17 so we are also dependent on aws/aws-lambda-base-images#29.

@jumpinjan
Copy link

+1. I would like support for spring boot 3 also. Starting a green field project so I want use Spring boot 3 instead of 2.

@cannonrush
Copy link

We are also eager to upgrade to SB3!
Given Java 17 is now officially supported as a Lambda runtime and the necessary changes seem to have been made on the main branch here, when can we expect an SB3-compatible version of aws-serverless to become available?

@deki
Copy link
Collaborator

deki commented May 15, 2023

We are depending on a commons-fileupload release which is unfortunately not yet available (https://issues.apache.org/jira/browse/FILEUPLOAD-309). However to not further delay a release we are thinking to provide a 2.0.0-M1 version very soon.

Until then feel free to build a SNAPSHOT version on your own and provide feedback.

@deki
Copy link
Collaborator

deki commented May 19, 2023

2.0.0-M1 (without commons-fileupload support) is now available on Maven Central.

@milindrao
Copy link

I can't find 2.0.0-M1 on Maven central. A link would be appreciated.

@deki
Copy link
Collaborator

deki commented Jul 19, 2023

@milindrao https://repo1.maven.org/maven2/com/amazonaws/serverless/aws-serverless-java-container-springboot3/2.0.0-M1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests