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

[bug] 2023.0.0.0-RC1 Not Supported graalvm #3656

Closed
lmm1990 opened this issue Mar 14, 2024 · 11 comments
Closed

[bug] 2023.0.0.0-RC1 Not Supported graalvm #3656

lmm1990 opened this issue Mar 14, 2024 · 11 comments

Comments

@lmm1990
Copy link

lmm1990 commented Mar 14, 2024

我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。另外请按照如下要求提交相关信息节省社区维护同学的理解成本,否则该讨论极有可能直接被忽视或关闭。
We recommend using English. If you are non-native English speaker, you can use the translation software. We recommend using English. If you are non-native English speaker, you can use the translation software. In addition, please submit relevant information according to the following requirements to save the understanding cost of community maintenances, otherwise the discussion is very likely to be ignored or closed directly.

Which Component
Nacos Discovery

Describe the bug
2024-03-14 14:27:13.669 WARN 1 --- [ main] com.alibaba.nacos.common.remote.client : [f47bcefe-8c4d-455d-a274-f4b023c06781] Fail to connect to server on start up, error message = The program tried to reflectively invoke method public java.util.Map com.alibaba.nacos.api.remote.request.ConnectionSetupRequest.getAbilityTable() without it being registered for runtime reflection. Add public java.util.Map com.alibaba.nacos.api.remote.request.ConnectionSetupRequest.getAbilityTable() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help., start up retry times left: 1

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively invoke method public java.util.Map com.alibaba.nacos.api.remote.request.ConnectionSetupRequest.getAbilityTable() without it being registered for runtime reflection. Add public java.util.Map com.alibaba.nacos.api.remote.request.ConnectionSetupRequest.getAbilityTable() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.MissingReflectionRegistrationUtils.forQueriedOnlyExecutable(MissingReflectionRegistrationUtils.java:72)
at java.base@21.0.1/java.lang.reflect.Method.acquireMethodAccessor(Method.java:77)
at java.base@21.0.1/java.lang.reflect.Method.invoke(Method.java:577)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:688)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:772)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:479)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:318)
at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4719)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsBytes(ObjectMapper.java:3987)
at com.alibaba.nacos.common.utils.JacksonUtils.toJsonBytes(JacksonUtils.java:77)
at com.alibaba.nacos.common.remote.client.grpc.GrpcUtils.convertRequestToByte(GrpcUtils.java:106)
at com.alibaba.nacos.common.remote.client.grpc.GrpcUtils.convert(GrpcUtils.java:80)
at com.alibaba.nacos.common.remote.client.grpc.GrpcConnection.sendRequest(GrpcConnection.java:128)
at com.alibaba.nacos.common.remote.client.grpc.GrpcClient.connectToServer(GrpcClient.java:404)
at com.alibaba.nacos.common.remote.client.RpcClient.start(RpcClient.java:352)
at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.start(NamingGrpcClientProxy.java:117)
at com.alibaba.nacos.client.naming.remote.gprc.NamingGrpcClientProxy.(NamingGrpcClientProxy.java:110)
at com.alibaba.nacos.client.naming.remote.NamingClientProxyDelegate.(NamingClientProxyDelegate.java:79)
at com.alibaba.nacos.client.naming.NacosNamingService.init(NacosNamingService.java:103)
at com.alibaba.nacos.client.naming.NacosNamingService.(NacosNamingService.java:86)
at java.base@21.0.1/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base@21.0.1/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at com.alibaba.nacos.api.naming.NamingFactory.createNamingService(NamingFactory.java:59)
at com.alibaba.nacos.api.NacosFactory.createNamingService(NacosFactory.java:77)
at com.alibaba.cloud.nacos.NacosServiceManager.createNewNamingService(NacosServiceManager.java:99)
at com.alibaba.cloud.nacos.NacosServiceManager.buildNamingService(NacosServiceManager.java:90)
at com.alibaba.cloud.nacos.NacosServiceManager.getNamingService(NacosServiceManager.java:46)
at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.namingService(NacosServiceRegistry.java:193)
at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:68)
at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.register(AbstractAutoServiceRegistration.java:264)
at com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration.register(NacosAutoServiceRegistration.java:78)
at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.start(AbstractAutoServiceRegistration.java:156)
at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:119)
at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:49)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:451)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:384)
at org.springframework.boot.web.reactive.context.WebServerManager.start(WebServerManager.java:57)
at org.springframework.boot.web.reactive.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:41)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:288)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:471)
at java.base@21.0.1/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:260)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:205)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:978)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:334)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
at cc.metafusion.ad_desk_api.Application.main(Application.java:10)
at java.base@21.0.1/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

Simplest demo
build.gradle

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
    implementation 'com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:2023.0.0.0-RC1'
    implementation 'com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:2023.0.0.0-RC1'
}

bootBuildImage {
    imageName = "xxxx/${getProject().getName()}:$version"
    builder = "paketobuildpacks/builder-jammy-tiny:latest"
    runImage = "paketobuildpacks/run-jammy-tiny:latest"
    environment["BP_JVM_VERSION"] = "21"
    docker {
        host = "tcp://192.168.0.140:2375" //中间docker宿主机的地址
    }
}

To Reproduce
Steps to reproduce the behavior:

  1. new springboot project version:3.2.3
  2. import spring-cloud-starter-alibaba-nacos-discovery、spring-cloud-starter-alibaba-nacos-config
  3. run bootBuildImage
  4. run docker image, see log
  5. Exception occurred,no graalvm reflection
    NotifySubscriberRequest
    ConnectionSetupRequest
    AbstractConfigRequest

Expected behavior
running success

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
os: centos8
graalvm: 21

proposal
reflect-config.json add
{
"name": "com.alibaba.nacos.api.naming.remote.request.NotifySubscriberRequest",
"allDeclaredFields": true,
"allDeclaredConstructors": true,
"methods": [
{
"name": "getGroupName",
"parameterTypes": [ ]
},
{
"name": "getModule",
"parameterTypes": [ ]
},
{
"name": "getNamespace",
"parameterTypes": [ ]
},
{
"name": "getServiceInfo",
"parameterTypes": [ ]
},
{
"name": "getServiceName",
"parameterTypes": [ ]
},
{
"name": "setGroupName",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "setNamespace",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "setServiceInfo",
"parameterTypes": [
"com.alibaba.nacos.api.naming.pojo.ServiceInfo"
]
},
{
"name": "setServiceName",
"parameterTypes": [
"java.lang.String"
]
}
]
},
{
"name": "com.alibaba.nacos.api.remote.request.ConnectionSetupRequest",
"allDeclaredFields": true,
"allDeclaredConstructors": true,
"methods": [
{
"name": "getAbilityTable",
"parameterTypes": [ ]
},
{
"name": "getClientVersion",
"parameterTypes": [ ]
},
{
"name": "getLabels",
"parameterTypes": [ ]
},
{
"name": "getTenant",
"parameterTypes": [ ]
},
{
"name": "setAbilityTable",
"parameterTypes": [
"java.util.Map"
]
},
{
"name": "setClientVersion",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "setLabels",
"parameterTypes": [
"java.util.Map"
]
},
{
"name": "setTenant",
"parameterTypes": [
"java.lang.String"
]
}
]
},
{
"name": "com.alibaba.nacos.api.config.remote.request.AbstractConfigRequest",
"allDeclaredFields": true,
"allDeclaredConstructors": true,
"methods": [
{
"name": "getDataId",
"parameterTypes": [ ]
},
{
"name": "getGroup",
"parameterTypes": [ ]
},
{
"name": "getModule",
"parameterTypes": [ ]
},
{
"name": "getTenant",
"parameterTypes": [ ]
},
{
"name": "setDataId",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "setGroup",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "setTenant",
"parameterTypes": [
"java.lang.String"
]
}
]
}

@yuluo-yx
Copy link
Collaborator

Can you provide a demo reproduction?

@yuluo-yx yuluo-yx changed the title 【bug】2023.0.0.0-RC1 Not Supported graalvm [bug] 2023.0.0.0-RC1 Not Supported graalvm Mar 14, 2024
@lmm1990
Copy link
Author

lmm1990 commented Mar 14, 2024

com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: CANCELLED: Failed to read message.
at com.alibaba.nacos.shaded.io.grpc.Status.asRuntimeException(Status.java:539)
at com.alibaba.nacos.shaded.io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:487)
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:563)
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70)
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:744)
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:723)
at com.alibaba.nacos.shaded.io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at com.alibaba.nacos.shaded.io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
at java.base@21.0.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base@21.0.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base@21.0.1/java.lang.Thread.runWith(Thread.java:1596)
at java.base@21.0.1/java.lang.Thread.run(Thread.java:1583)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:837)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:211)
Caused by: org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively invoke method public void com.alibaba.nacos.api.config.remote.request.ConfigChangeNotifyRequest.setTenant(java.lang.String) without it being registered for runtime reflection. Add public void com.alibaba.nacos.api.config.remote.request.ConfigChangeNotifyRequest.setTenant(java.lang.String) to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.MissingReflectionRegistrationUtils.forQueriedOnlyExecutable(MissingReflectionRegistrationUtils.java:72)
at java.base@21.0.1/java.lang.reflect.Method.acquireMethodAccessor(Method.java:77)
at java.base@21.0.1/java.lang.reflect.Method.invoke(Method.java:577)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:141)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4730)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3714)
at com.alibaba.nacos.common.utils.JacksonUtils.toObj(JacksonUtils.java:128)
at com.alibaba.nacos.common.remote.client.grpc.GrpcUtils.parse(GrpcUtils.java:126)
at com.alibaba.nacos.common.remote.client.grpc.GrpcClient$1.onNext(GrpcClient.java:239)
at com.alibaba.nacos.common.remote.client.grpc.GrpcClient$1.onNext(GrpcClient.java:231)
at com.alibaba.nacos.shaded.io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onMessage(ClientCalls.java:474)
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInternal(ClientCallImpl.java:662)
at com.alibaba.nacos.shaded.io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1MessagesAvailable.runInContext(ClientCallImpl.java:647)
... 8 common frames omitted


ConfigChangeNotifyRequest
reflect-config.json need add


{
"name": "com.alibaba.nacos.api.config.remote.request.ConfigChangeNotifyRequest",
"allDeclaredConstructors": true,
"allDeclaredFields": true,
"methods": [
{
"name": "setGroup",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "getTenant",
"parameterTypes": [ ]
},
{
"name": "setTenant",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "setDataId",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "getGroup",
"parameterTypes": [ ]
},
{
"name": "getDataId",
"parameterTypes": [ ]
},
{
"name": "getModule",
"parameterTypes": [ ]
}
]
}

@lmm1990
Copy link
Author

lmm1990 commented Mar 14, 2024

@yuluo-yx see project demo.zip
demo.zip

You need replace nacos config and docker config

I use spring aot.factories generate reflect-config.json

@yuluo-yx
Copy link
Collaborator

yuluo-yx commented Mar 14, 2024

I use . /gradlew nativeCompile compilation can successfully execute the binary. From the logs, it looks like it's nacos that's reporting the error, so you can check the docker container and nacos connectivity to see how it's working.

@yuluo-yx
Copy link
Collaborator

BTW, The examples provided by spring cloud alibaba are compiled and tested by graalvm native, you can refer to the code in the examples to run the.

@lmm1990
Copy link
Author

lmm1990 commented Mar 15, 2024

@yuluo-yx nacos-client-2.3.0.jar!\META-INF\native-image\com.alibaba.nacos\nacos-client\reflect-config.json

{
  "name":"com.alibaba.nacos.api.remote.request.ConnectionSetupRequest",
  "allDeclaredFields":true,
  "queryAllDeclaredMethods":true,
  "queryAllDeclaredConstructors":true,
  "methods":[
    {"name":"getAbilities","parameterTypes":[] }, 
    {"name":"getClientVersion","parameterTypes":[] }, 
    {"name":"getLabels","parameterTypes":[] }, 
    {"name":"getTenant","parameterTypes":[] }
  ]
}

Lack of methods ConnectionSetupRequest.getAbilityTable() config

suggest:
When compiling packages,Dynamically generated reflect-config.json

@lmm1990
Copy link
Author

lmm1990 commented Mar 15, 2024

In this way, after modifying the code, reflect-config.json is also new

@chickenlj
Copy link
Collaborator

@yuluo-yx nacos-client-2.3.0.jar!\META-INF\native-image\com.alibaba.nacos\nacos-client\reflect-config.json

{
  "name":"com.alibaba.nacos.api.remote.request.ConnectionSetupRequest",
  "allDeclaredFields":true,
  "queryAllDeclaredMethods":true,
  "queryAllDeclaredConstructors":true,
  "methods":[
    {"name":"getAbilities","parameterTypes":[] }, 
    {"name":"getClientVersion","parameterTypes":[] }, 
    {"name":"getLabels","parameterTypes":[] }, 
    {"name":"getTenant","parameterTypes":[] }
  ]
}

Lack of methods ConnectionSetupRequest.getAbilityTable() config

suggest: When compiling packages,Dynamically generated reflect-config.json

@lmm1990 Could you please file a pull request to add the above item into reflect-config.json. Thanks.

We will think of the auto-generated way later.

@lmm1990
Copy link
Author

lmm1990 commented Mar 20, 2024

fixed alibaba/nacos#11860

@yuluo-yx yuluo-yx added the kind/bug Mark as bug label Mar 21, 2024
Copy link

This issue has been open 30 days with no activity. This will be closed in 7 days.

@github-actions github-actions bot added the stale label Apr 21, 2024
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity.If you think this should still be open, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up. Thank you for your interest and contribution to the Sping Cloud Alibaba Community.

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

3 participants