aws / aws-xray-sdk-java

The official AWS X-Ray Recorder SDK for Java.
Apache License 2.0
95 stars 99 forks source link

[GraalVM] No serializer found for class com.amazonaws.services.xray.model.GetSamplingRulesRequest #324

Open smoell opened 2 years ago

smoell commented 2 years ago

Hi all,

I've implemented a Spring Boot application using Spring Native and GraalVM. With JDK 17 everything works fine, application runs without an issue in Amazon ECS with AWS Fargate, but using GraalVM (graalvm-ce-java17-22.0.0.2), I get the follwing error when trying to send a sampling request:

2022-02-27 10:14:44.637  INFO 1 --- [           main] o.s.nativex.NativeListener               : AOT mode enabled
--
.   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ \| '_ \| '_\| \| '_ \/ _` \| \ \ \ \
\\/  ___)\| \|_)\| \| \| \| \| \|\| (_\| \|  ) ) ) )
'  \|____\| .__\|_\| \|_\|_\| \|_\__, \| / / / /
=========\|_\|==============\|___/=/_/_/_/
:: Spring Boot ::                (v2.6.3)
2022-02-27 10:14:44.639  INFO 1 --- [           main] c.a.c.CustomerServiceApplication         : Starting CustomerServiceApplication v0.0.1 using Java 17.0.2 on ip-10-0-202-97.eu-west-1.compute.internal with PID 1 (/CustomerService started by nonroot in /)
2022-02-27 10:14:44.639  INFO 1 --- [           main] c.a.c.CustomerServiceApplication         : The following profiles are active: prod
2022-02-27 10:14:44.680  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-02-27 10:14:44.681  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-02-27 10:14:44.681  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
2022-02-27 10:14:44.684  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-02-27 10:14:44.684  INFO 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 43 ms
2022-02-27 10:14:44.695  WARN 1 --- [           main] i.m.c.i.binder.jvm.JvmGcMetrics          : GC notifications will not be available because MemoryPoolMXBeans are not provided by the JVM
2022-02-27 10:14:44.753  INFO 1 --- [           main] o.s.aop.framework.BuildTimeAopProxy      : Attempting discovery (load) of build time generated proxy for class: com.amazon.customerService.repository.CustomerRepository
2022-02-27 10:14:44.753  INFO 1 --- [           main] o.s.aop.framework.BuildTimeAopProxy      : Suitable proxy found with name com.amazon.customerService.repository.CustomerRepository$SpringProxy$e41e6620
2022-02-27 10:14:44.753  INFO 1 --- [           main] o.s.aop.framework.BuildTimeAopProxy      : Attempting discovery (load) of build time generated proxy for class: com.amazon.customerService.service.CustomerService
2022-02-27 10:14:44.753  INFO 1 --- [           main] o.s.aop.framework.BuildTimeAopProxy      : Suitable proxy found with name com.amazon.customerService.service.CustomerService$SpringProxy$53cd29c2
2022-02-27 10:14:44.873  INFO 1 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2022-02-27 10:14:44.875  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2022-02-27 10:14:44.876  INFO 1 --- [           main] c.a.c.CustomerServiceApplication         : Started CustomerServiceApplication in 0.249 seconds (JVM running for 0.251)
2022-02-27 10:15:01.026  INFO 1 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-02-27 10:15:01.026  INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-02-27 10:15:01.027  INFO 1 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2022-02-27 10:15:01.028  INFO 1 --- [pool-4-thread-1] c.a.x.s.sampling.pollers.RulePoller      : Polling sampling rules.
2022-02-27 10:15:01.030  INFO 1 --- [pool-4-thread-1] c.a.x.s.sampling.pollers.RulePoller      : Encountered error polling GetSamplingRules:
com.amazonaws.xray.internal.XrayClientException: Could not serialize and send request.
at com.amazonaws.xray.internal.UnsignedXrayClient.sendRequest(UnsignedXrayClient.java:142) ~[na:na]
at com.amazonaws.xray.internal.UnsignedXrayClient.getSamplingRules(UnsignedXrayClient.java:112) ~[na:na]
at com.amazonaws.xray.strategy.sampling.pollers.RulePoller.pollRule(RulePoller.java:100) ~[na:na]
at com.amazonaws.xray.strategy.sampling.pollers.RulePoller.lambda$start$0(RulePoller.java:72) ~[na:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[na:na]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
at java.lang.Thread.run(Thread.java:833) ~[na:na]
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:597) ~[na:na]
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:194) ~[na:na]
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.amazonaws.services.xray.model.GetSamplingRulesRequest and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1300) ~[na:na]
at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400) ~[na:na]
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:46) ~[na:na]
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:29) ~[na:na]
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480) ~[na:na]
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319) ~[na:na]
at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4568) ~[CustomerService:2.13.1]
at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3780) ~[CustomerService:2.13.1]
at com.amazonaws.xray.internal.UnsignedXrayClient.sendRequest(UnsignedXrayClient.java:140) ~[na:na]
... 11 common frames omitted
msailes commented 2 years ago

Hi @smoell,

The com.amazonaws.services.xray.model.GetSamplingRulesRequest class is actually part of the AWS SDK for Java - X-Ray module. Not part of the aws-xray-sdk-java lib. Do you have a sample application you could share to show this error?

ivyblossom commented 2 years ago

@msailes I get the same "Could not serialize and send request" when I followed https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-aop-spring.html