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

AmazonLambdaRecorder.chooseHandlerClass needs to support RequestStreamHandler pattern #6707

Closed
stdunbar opened this issue Jan 21, 2020 · 9 comments

Comments

@stdunbar
Copy link

stdunbar commented Jan 21, 2020

I'm unable to get the out of the box AWS Lambda test to work if my Lambda uses the RequestStreamHandler implementation pattern. My code:

@Named("lambdaHandler")
public class LambdaHandler implements RequestStreamHandler {
    public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) {
        context.getLogger().log( "starting " + this.getClass().getName() );
    }
}

And my application.properties has quarkus.lambda.handler=lambdaHandler. At times it is easier to read the InputStream and parse what you need out of it rather than creating a POJO. As it is I get:

2020-01-21 14:30:08,111 ERROR [io.qua.application] (main) Failed to start application: java.lang.RuntimeException: Unable to find handler class with name lambdaHandler make sure there is a handler class in the deployment with the correct @Named annotation
    at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.chooseHandlerClass(AmazonLambdaRecorder.java:98)
    at io.quarkus.deployment.steps.AmazonLambdaProcessor$recordHandlerClass32.deploy_0(AmazonLambdaProcessor$recordHandlerClass32.zig:110)
    at io.quarkus.deployment.steps.AmazonLambdaProcessor$recordHandlerClass32.deploy(AmazonLambdaProcessor$recordHandlerClass32.zig:129)
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:172)
    at io.quarkus.runtime.Application.start(Application.java:87)

Perhaps the quarkus.lambda.handler could work like the AWS Lambda environment and accept a full package name with method name, i.e. com.example.lambda.handler.LambdaHander::myHandler

@gsmet
Copy link
Member

gsmet commented Jan 31, 2020

@evanchooly could you have a look at that one?

@jmkgreen
Copy link

I am seeing exactly the same. If it implements RequestHandler it seems to work.

According to https://quarkus.io/guides/amazon-lambda#choose-your-lambda only RequestHandler implementations are scanned for, which may be why.

I am building against RequestHandler because I want to use Jackson. The documentation for Quarkus mentioning Jackson does not make clear whether the integration is purely for REST API interfaces or for others such as Amazon Lambda too (which would render my work here redundant).

@PhilAndrew
Copy link

PhilAndrew commented Feb 17, 2020

If I follow the application builder to create the AWS Lambda application then ./mvnw compile quarkus:dev I get the following error.

In other words it does not work following those steps.

Listening for transport dt_socket at address: 5005
2020-02-18 09:37:23,524 ERROR [io.qua.application] (main) Failed to start application: java.lang.RuntimeException: Unable to find handler class, make sure your deployment includes a com.amazonaws.services.lambda.runtime.RequestHandler implementation
	at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.chooseHandlerClass(AmazonLambdaRecorder.java:110)
	at io.quarkus.deployment.steps.AmazonLambdaProcessor$recordHandlerClass31.deploy_0(AmazonLambdaProcessor$recordHandlerClass31.zig:129)
	at io.quarkus.deployment.steps.AmazonLambdaProcessor$recordHandlerClass31.deploy(AmazonLambdaProcessor$recordHandlerClass31.zig:36)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:172)
	at io.quarkus.runtime.Application.start(Application.java:87)
	at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:167)
	at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:178)
	at io.quarkus.dev.DevModeMain.start(DevModeMain.java:96)
	at io.quarkus.dev.DevModeMain.main(DevModeMain.java:67)

2020-02-18 09:37:23,546 ERROR [io.qua.dev.DevModeMain] (main) Failed to start Quarkus: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:202)
	at io.quarkus.runtime.Application.start(Application.java:87)
	at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:167)
	at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:178)
	at io.quarkus.dev.DevModeMain.start(DevModeMain.java:96)
	at io.quarkus.dev.DevModeMain.main(DevModeMain.java:67)
Caused by: java.lang.RuntimeException: Unable to find handler class, make sure your deployment includes a com.amazonaws.services.lambda.runtime.RequestHandler implementation
	at io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.chooseHandlerClass(AmazonLambdaRecorder.java:110)
	at io.quarkus.deployment.steps.AmazonLambdaProcessor$recordHandlerClass31.deploy_0(AmazonLambdaProcessor$recordHandlerClass31.zig:129)
	at io.quarkus.deployment.steps.AmazonLambdaProcessor$recordHandlerClass31.deploy(AmazonLambdaProcessor$recordHandlerClass31.zig:36)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:172)
	... 5 more

@geniusit
Copy link

geniusit commented Mar 6, 2020

+1

@gsmet
Copy link
Member

gsmet commented Mar 6, 2020

Can one of you provide a reproducer?

/cc @patriot1burke @evanchooly

@patriot1burke
Copy link
Contributor

No need for a producer. I understand the problem. WE don't support stream handler.

@patriot1burke
Copy link
Contributor

This is a feature request, not a bug.

@geniusit
Copy link

geniusit commented Mar 7, 2020

Unfortunately, the S3Event object doesn't work with native image .
I ve open an issue for it :#7670
How to retrieve bucket + key informations with the native image ?

@oztimpower
Copy link
Contributor

Please close, this was added by #7866

@gsmet gsmet added this to the 1.4.0.CR1 milestone May 25, 2020
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

8 participants