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] Cannot make a java.lang.Class constructor accessible #2356

Closed
q920447939 opened this issue Mar 21, 2024 · 3 comments
Closed

[BUG] Cannot make a java.lang.Class constructor accessible #2356

q920447939 opened this issue Mar 21, 2024 · 3 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@q920447939
Copy link

问题描述

已经增加启动参数 -Dspring.profiles.active=dev -Dproject.name=dubbo-consumer-dubbo -Dcom.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.tryReflectionSetAccessible=true -Dio.netty.tryReflectionSetAccessible=true --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED
在使用dubbo的时,提示序列化错误

Failed to invoke the method queryUser in the service com.example.dubboapi.Api. Tried 3 times of the providers [192.168.22.235:20880] (1/1) from the registry 127.0.0.1:8848 on the consumer 192.168.22.235 using the dubbo version 3.2.6. Last error is: Failed to invoke remote method: queryUser, provider: DefaultServiceInstance{serviceName='dubbo-api-dubbo', host='192.168.22.235', port=20880, enabled=true, healthy=true, metadata={dubbo.metadata-service.url-params={"prefer.serialization":"fastjson2,hessian2","version":"1.0.0","dubbo":"2.0.2","release":"3.2.6","side":"provider","port":"20880","protocol":"dubbo"}, dubbo.endpoints=[{"port":20880,"protocol":"dubbo"}], dubbo.metadata.revision=0593f64fe3159790d8adb0351cd23ec9, dubbo.metadata.storage-type=local, timestamp=1710901980602}}, service{name='com.example.dubboapi.Api',group='null',version='null',protocol='dubbo',port='20880',params={side=provider, release=3.2.6, methods=queryUser, deprecated=false, dubbo=2.0.2, interface=com.example.dubboapi.Api, service-name-mapping=true, generic=false, serialize.check.status=DISABLE, auto.trust.serialize.class=true, application=dubbo-api-dubbo, prefer.serialization=fastjson2,hessian2, trust.serialize.class.level=3, dynamic=true},}, cause: org.apache.dubbo.remoting.RemotingException: java.io.IOException: org.apache.dubbo.common.serialize.SerializationException: java.lang.SecurityException: Cannot make a java.lang.Class constructor accessible
java.io.IOException: org.apache.dubbo.common.serialize.SerializationException: java.lang.SecurityException: Cannot make a java.lang.Class constructor accessible
	at org.apache.dubbo.common.serialize.DefaultSerializationExceptionWrapper.handleToIOException(DefaultSerializationExceptionWrapper.java:358)
	at org.apache.dubbo.common.serialize.DefaultSerializationExceptionWrapper.access$000(DefaultSerializationExceptionWrapper.java:28)
	at org.apache.dubbo.common.serialize.DefaultSerializationExceptionWrapper$ProxyObjectInput.readThrowable(DefaultSerializationExceptionWrapper.java:186)
	at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.handleException(DecodeableRpcResult.java:182)
	at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:114)
	at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:149)
	at org.apache.dubbo.remoting.transport.DecodeHandler.decode(DecodeHandler.java:62)
	at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:50)
	at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:62)
	at org.apache.dubbo.common.threadpool.ThreadlessExecutor$RunnableWrapper.run(ThreadlessExecutor.java:152)
	at org.apache.dubbo.common.threadpool.ThreadlessExecutor.waitAndDrain(ThreadlessExecutor.java:77)
	at org.apache.dubbo.rpc.AsyncRpcResult.get(AsyncRpcResult.java:205)
	at org.apache.dubbo.rpc.protocol.AbstractInvoker.waitForResultIfSync(AbstractInvoker.java:287)
	at org.apache.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:190)
	at org.apache.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:71)
	at org.apache.dubbo.rpc.filter.RpcExceptionFilter.invoke(RpcExceptionFilter.java:41)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:196)
	at org.apache.dubbo.rpc.protocol.ReferenceCountInvokerWrapper.invoke(ReferenceCountInvokerWrapper.java:88)
	at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invokeWithContext(AbstractClusterInvoker.java:383)
	at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:80)
	at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:344)
	at org.apache.dubbo.rpc.cluster.router.RouterSnapshotFilter.invoke(RouterSnapshotFilter.java:46)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:108)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.rpc.cluster.filter.support.MetricsClusterFilter.invoke(MetricsClusterFilter.java:56)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:52)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.rpc.cluster.filter.support.ObservationSenderFilter.invoke(ObservationSenderFilter.java:61)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.spring.security.filter.ContextHolderParametersSelectedTransferFilter.invoke(ContextHolderParametersSelectedTransferFilter.java:41)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.metrics.filter.MetricsFilter.invoke(MetricsFilter.java:73)
	at org.apache.dubbo.rpc.cluster.filter.support.MetricsConsumerFilter.invoke(MetricsConsumerFilter.java:37)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.rpc.cluster.filter.support.ConsumerClassLoaderFilter.invoke(ConsumerClassLoaderFilter.java:40)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter.invoke(ConsumerContextFilter.java:116)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:334)
	at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:196)
	at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$ClusterFilterInvoker.invoke(AbstractCluster.java:91)
	at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:103)
	at org.apache.dubbo.rpc.cluster.support.wrapper.ScopeClusterInvoker.invoke(ScopeClusterInvoker.java:169)
	at org.apache.dubbo.registry.client.migration.MigrationInvoker.invoke(MigrationInvoker.java:284)
	at org.apache.dubbo.rpc.proxy.InvocationUtil.invoke(InvocationUtil.java:61)
	at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:75)
	at com.example.dubboapi.ApiDubboProxy0.queryUser(ApiDubboProxy0.java)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.dubbo.config.spring.util.LazyTargetInvocationHandler.invoke(LazyTargetInvocationHandler.java:58)
	at com.example.dubboapi.ApiDubboProxy0.queryUser(ApiDubboProxy0.java)
	at com.example.dubboconsumer.Init.run(Init.java:24)
	at org.springframework.boot.SpringApplication.lambda$callRunner$4(SpringApplication.java:786)
	at org.springframework.util.function.ThrowingConsumer$1.acceptWithException(ThrowingConsumer.java:83)
	at org.springframework.util.function.ThrowingConsumer.accept(ThrowingConsumer.java:60)
	at org.springframework.util.function.ThrowingConsumer$1.accept(ThrowingConsumer.java:88)
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798)
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:786)
	at org.springframework.boot.SpringApplication.lambda$callRunners$3(SpringApplication.java:774)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:774)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:341)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
	at com.example.dubboconsumer.DubboConsumerApplication.main(DubboConsumerApplication.java:14)
Caused by: org.apache.dubbo.common.serialize.SerializationException: java.lang.SecurityException: Cannot make a java.lang.Class constructor accessible
	... 76 more
Caused by: java.lang.SecurityException: Cannot make a java.lang.Class constructor accessible
	at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:191)
	at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
	at com.alibaba.fastjson2.reader.ObjectReaderCreator.createObjectReader(ObjectReaderCreator.java:1072)
	at com.alibaba.fastjson2.reader.ObjectReaderCreatorASM.createObjectReader(ObjectReaderCreatorASM.java:308)
	at com.alibaba.fastjson2.reader.ObjectReaderProvider.getObjectReaderInternal(ObjectReaderProvider.java:854)
	at com.alibaba.fastjson2.reader.ObjectReaderProvider.getObjectReader(ObjectReaderProvider.java:746)
	at com.alibaba.fastjson2.JSONReader.getObjectReader(JSONReader.java:401)
	at com.alibaba.fastjson2.reader.FieldReaderObject.getObjectReader(FieldReaderObject.java:70)
	at com.alibaba.fastjson2.reader.ORG_5_4_ConstraintAnnotationDescriptor.readJSONBObject(Unknown Source)
	at com.alibaba.fastjson2.reader.ORG_4_14_ConstraintDescriptorImpl.readJSONBObject(Unknown Source)
	at com.alibaba.fastjson2.reader.ObjectReaderInterface.readJSONBObject(ObjectReaderInterface.java:36)
	at com.alibaba.fastjson2.reader.ORG_3_14_ConstraintViolationImpl.readJSONBObject(Unknown Source)
	at com.alibaba.fastjson2.reader.ObjectReaderImplList.readJSONBObject(ObjectReaderImplList.java:517)
	at com.alibaba.fastjson2.reader.FieldReaderObject.readFieldValue(FieldReaderObject.java:294)
	at com.alibaba.fastjson2.reader.ObjectReaderException.readObject(ObjectReaderException.java:220)
	at com.alibaba.fastjson2.reader.ObjectReaderException.readJSONBObject(ObjectReaderException.java:375)
	at com.alibaba.fastjson2.JSONReaderJSONB.readAnyObject(JSONReaderJSONB.java:1302)
	at com.alibaba.fastjson2.JSONB.parseObject(JSONB.java:587)
	at org.apache.dubbo.common.serialize.fastjson2.FastJson2ObjectInput.readObject(FastJson2ObjectInput.java:118)
	at org.apache.dubbo.common.serialize.fastjson2.FastJson2ObjectInput.readObject(FastJson2ObjectInput.java:103)
	at org.apache.dubbo.common.serialize.ObjectInput.readThrowable(ObjectInput.java:74)
	at org.apache.dubbo.common.serialize.DefaultSerializationExceptionWrapper$ProxyObjectInput.readThrowable(DefaultSerializationExceptionWrapper.java:184)
	... 73 more

环境信息

请填写以下信息:

  • OS信息: [Windows]
  • JDK信息:
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)

  • 版本信息:[e.g.:Fastjson2 2.0.47 Fastjson 2.0.47]

重现步骤

如何操作可以重现该问题:

使用下面的例子重现
https://github.com/q920447939/dubbo-test

期待的正确结果

预期能调用序列化正常

相关日志输出

上方已粘贴报错信息

附加信息

在dubbo 已提issue ,dubbo说是fastjson2的问题 。issue地址:apache/dubbo#13952

@q920447939 q920447939 added the bug Something isn't working label Mar 21, 2024
@wenshao wenshao added this to the 2.0.48 milestone Mar 21, 2024
@wenshao
Copy link
Member

wenshao commented Mar 21, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.48-SNAPSHOT/ 问题已修复,请帮忙用2.0.48-SNAPSHOT验证,2.0.48正式版本预计在月末发布

@wenshao wenshao added the fixed label Mar 21, 2024
@q920447939
Copy link
Author

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.48-SNAPSHOT/ 问题已修复,请帮忙用2.0.48-SNAPSHOT验证,2.0.48正式版本预计在月末发布

@wenshao 请问这个快照版在哪个仓库可以下载?

@wenshao
Copy link
Member

wenshao commented Mar 25, 2024

@wenshao wenshao closed this as completed Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants