I having a problem deploying the simplest Spring Cloud Function application to AWS Lambda using a docker image.
@SpringBootApplication
public class GraalvmFuncExampleApplication {
public static void main(String[] args) {
SpringApplication.run(GraalvmFuncExampleApplication.class, args);
}
@Bean
public Function<Mono<MyRequest>, Mono<MyResponse>> transform() {
return req -> {
return req.flatMap(r -> Mono.just(MyResponse.builder().name(r.getName().toUpperCase()).build()));
};
}
}
Dependencies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>vlad.dev</groupId>
<artifactId>graalvm-func-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>graalvm-func-example</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2022.0.4</spring-cloud.version>
<start-class>com.amazonaws.services.lambda.runtime.api.client.AWSLambda</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-parent</artifactId>
<version>4.0.4</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-runtime-interface-client</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-adapter-aws</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-function-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
The error I get:
14:07:40.192 [main] INFO org.springframework.cloud.function.utils.FunctionClassUtils -- Main class: class com.amazonaws.services.lambda.runtime.api.client.AWSLambda
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _
( ( )___ | '_ | '_| | '_ / _` |
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.2)
2023-08-12T14:07:42.761Z INFO 9 --- [ main] o.s.c.f.a.aws.CustomRuntimeInitializer : AWS Handler: org.springframework.cloud.function.adapter.aws.FunctionInvoker
2023-08-12T14:07:42.824Z INFO 9 --- [ main] c.a.s.l.runtime.api.client.AWSLambda : Starting AWSLambda v2.1.1 using Java 17.0.3 with PID 9 (/var/runtime/lib/aws-lambda-java-runtime-interface-client-2.1.1.jar started by sbx_user1051 in /)
2023-08-12T14:07:42.826Z INFO 9 --- [ main] c.a.s.l.runtime.api.client.AWSLambda : No active profile set, falling back to 1 default profile: "default"
2023-08-12T14:07:43.969Z INFO 9 --- [ main] c.a.s.l.runtime.api.client.AWSLambda : Started AWSLambda in 2.857 seconds (process running for 4.037)
No qualifying bean of type 'org.springframework.cloud.function.context.FunctionCatalog' available: org.springframework.beans.factory.NoSuchBeanDefinitionException
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.function.context.FunctionCatalog' available
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:341)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:332)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1173)
at org.springframework.cloud.function.adapter.aws.FunctionInvoker.start(FunctionInvoker.java:109)
at org.springframework.cloud.function.adapter.aws.FunctionInvoker.<init>(FunctionInvoker.java:71)
at org.springframework.cloud.function.adapter.aws.FunctionInvoker.<init>(FunctionInvoker.java:79)
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)
START RequestId: 6368b3eb-605f-490b-bc2e-f74972623968 Version: $LATEST
2023-08-12T14:08:35.442Z 6368b3eb-605f-490b-bc2e-f74972623968 Task timed out after 3.09 seconds
Any idea why I get the "No qualifying bean of type ‘org.springframework.cloud.function.context.FunctionCatalog’ available: org.springframework.beans.factory.NoSuchBeanDefinitionException" on cloud.
It works just fine on my local non-cloud environment.
2
Answers
Your pom has spring-cloud-function-parent which does not look right, below a regular pom for cloud function
here is AWS spring cloud example pom dependencies
in your case, can you try to change your dependencies like below
I concur with @ozkanpakdil, the parent always has to be
and then let s-cloud manager the dependency versions for you