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

4.1.3 getting ClassCastException when integrating with AWS lambda functions #1161

Open
danMarshmallow opened this issue Jul 11, 2024 · 2 comments

Comments

@danMarshmallow
Copy link

bump to version 4.1.3 breaking our integration to aws lambda with this stack trace:

class [B cannot be cast to class XXX.events.LambdaBatch ([B is in module java.base of loader 'bootstrap'; 
XXX.events.LambdaBatch is in unnamed module of loader com.amazonaws.services.lambda.runtime.api.client.CustomerClassLoader @3cc41abc): java.lang.ClassCastException
java.lang.ClassCastException: class [B cannot be cast to class XXX.events.LambdaBatch ([B is in module java.base of loader 'bootstrap'; XXX.events.LambdaBatch is in unnamed module of loader com.amazonaws.services.lambda.runtime.api.client.CustomerClassLoader @3cc41abc)
	at XXX.lambdas.AddOnLoggingLambda.accept(AddOnLoggingLambda.java:19)
	at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.invokeConsumer(SimpleFunctionRegistry.java:1063)
	at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.doApply(SimpleFunctionRegistry.java:761)
	at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.apply(SimpleFunctionRegistry.java:592)
	at org.springframework.cloud.function.adapter.aws.FunctionInvoker.handleRequest(FunctionInvoker.java:91)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)

the class that throwing the exception looks like that:

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.function.Consumer;


@Slf4j
@Component
@RequiredArgsConstructor
public class AddOnLoggingLambda implements Consumer<LambdaBatch> {

    @Override
    public void accept(final LambdaBatch events) {
        // logic here
    }
}
@olegz
Copy link
Contributor

olegz commented Oct 7, 2024

Any chance you can provide a reproducible sample?

@olegz
Copy link
Contributor

olegz commented Oct 17, 2024

Can you post LambdaBatch class? The issue appears to be that none of the provided converters was able to convert your input to LambdaBatch, hence request is passed raw

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

No branches or pull requests

2 participants