serverless-java-container icon indicating copy to clipboard operation
serverless-java-container copied to clipboard

Migration from 2.0.0-M2 to newer version

Open lugolu opened this issue 1 year ago • 1 comments

Serverless Java Container version: >=2.0.0

Implementations: Spring Boot 3

Framework version: SpringBoot 3.2.2.RELEASE

Frontend service: REST API

Deployment method: SAM

Java: 17 (i've tried updating to 21, according on template is used runtime 21 instead of runtime 17. and same error)

Scenario

I'm trying to migrate an existing lambda from 2.0.0-M2 to a newer version. I've tried all versiones from 2.0.0 to 2.0.3.

Expected behavior

Project should compile and tests executed ok.

Actual behavior

I'm getting cast errors when tests are executed.

Full log output

2024-10-11T12:49:27.104-03:00  WARN 31968 --- [           main] o.s.w.c.s.GenericWebApplicationContext   : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletWebServerFactory' defined in class path resource [org/springframework/cloud/function/serverless/web/ServerlessAutoConfiguration.class]: class org.springframework.web.context.support.GenericWebApplicationContext cannot be cast to class org.springframework.boot.web.context.ConfigurableWebServerApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext and org.springframework.boot.web.context.ConfigurableWebServerApplicationContext are in unnamed module of loader 'app')
2024-10-11T12:49:27.114-03:00  INFO 31968 --- [           main] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-10-11T12:49:27.139-03:00 ERROR 31968 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletWebServerFactory' defined in class path resource [org/springframework/cloud/function/serverless/web/ServerlessAutoConfiguration.class]: class org.springframework.web.context.support.GenericWebApplicationContext cannot be cast to class org.springframework.boot.web.context.ConfigurableWebServerApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext and org.springframework.boot.web.context.ConfigurableWebServerApplicationContext are in unnamed module of loader 'app')
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:606) ~[spring-beans-6.1.3.jar:6.1.3]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.1.3.jar:6.1.3]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325) ~[spring-beans-6.1.3.jar:6.1.3]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.3.jar:6.1.3]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323) ~[spring-beans-6.1.3.jar:6.1.3]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.1.3.jar:6.1.3]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) ~[spring-beans-6.1.3.jar:6.1.3]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:959) ~[spring-context-6.1.3.jar:6.1.3]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) ~[spring-context-6.1.3.jar:6.1.3]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.2.2.jar:3.2.2]

lugolu avatar Oct 11 '24 15:10 lugolu

Hi, thanks for your issue report. Looks like this is already reported in #904. We are waiting for a new spring-cloud-function release. As a workaround you can exclude the dependency for now.

deki avatar Oct 16 '24 13:10 deki

Fixed as part of the 2.1.0 release.

deki avatar Nov 27 '24 11:11 deki