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

3.2.7 invoking remote service in generic mode causes java.lang.ClassNotFoundException #13436

Closed
1 task done
hwding opened this issue Nov 29, 2023 · 0 comments · Fixed by #13442
Closed
1 task done

3.2.7 invoking remote service in generic mode causes java.lang.ClassNotFoundException #13436

hwding opened this issue Nov 29, 2023 · 0 comments · Fixed by #13442
Labels
type/bug Bugs to being fixed

Comments

@hwding
Copy link

hwding commented Nov 29, 2023

  • I have searched the issues of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 3.2.7
  • Operating System version: Linux 4.19.91-009.ali4000.alios7.x86_64 #1 SMP Mon Jan 25 10:47:38 CST 2021 x86_64 x86_64 x86_64 GNU/Linux
  • Java version: OpenJDK Runtime Environment (Alibaba 8.4.7) (build 1.8.0_152-b187) OpenJDK 64-Bit Server VM (Alibaba 8.4.7) (build 25.152-b187, mixed mode)

Steps to reproduce this issue

  1. define generic reference config
referenceConfig.setGeneric("true");
referenceConfig.setAsync(false);

genericService = referenceConfig.get();
  1. do invocation
// argTypes contain remote-defined-only class
genericService.$invoke(method, argTypes, args);

Pls. provide [GitHub address] to reproduce this issue.

Expected Behavior

Succeed in invoking remote service in generic mode.

Actual Behavior

Failed to invoke remote in generic mode, exception occurred in client side.

Caused by: org.apache.dubbo.rpc.StatusRpcException: INTERNAL : Call aborted cause client exception
  at org.apache.dubbo.rpc.TriRpcStatus.asException(TriRpcStatus.java:214) ~[dubbo-3.2.7.jar:3.2.7]
  at org.apache.dubbo.rpc.protocol.tri.TripleInvoker.doInvoke(TripleInvoker.java:166) ~[dubbo-3.2.7.jar:3.2.7]
  at org.apache.dubbo.rpc.protocol.AbstractInvoker.doInvokeAndReturn(AbstractInvoker.java:243) ~[dubbo-3.2.7.jar:3.2.7]
  at org.apache.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:187) ~[dubbo-3.2.7.jar:3.2.7]
  ... 295 common frames omitted
Caused by: java.lang.IllegalStateException: Not found class com.***.***DTO, cause: com.***.***DTO
  at org.apache.dubbo.common.utils.ReflectUtils.forName(ReflectUtils.java:685) ~[dubbo-3.2.7.jar:3.2.7]
  at org.apache.dubbo.rpc.support.RpcUtils.getParameterTypes(RpcUtils.java:169) ~[dubbo-3.2.7.jar:3.2.7]
  at org.apache.dubbo.rpc.protocol.tri.TripleInvoker.invokeUnary(TripleInvoker.java:251) ~[dubbo-3.2.7.jar:3.2.7]
  at org.apache.dubbo.rpc.protocol.tri.TripleInvoker.doInvoke(TripleInvoker.java:150) ~[dubbo-3.2.7.jar:3.2.7]
  ... 297 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.***.***DTO
  at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass(TomcatEmbeddedWebappClassLoader.java:72) ~[spring-boot-2.5.12.jar:2.5.12]
  at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1215) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
  at java.lang.Class.forName0(Native Method) ~[na:1.8.0_152]
  at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_152]
  at org.apache.dubbo.common.utils.ReflectUtils.name2class(ReflectUtils.java:786) ~[dubbo-3.2.7.jar:3.2.7]
  at org.apache.dubbo.common.utils.ReflectUtils.name2class(ReflectUtils.java:706) ~[dubbo-3.2.7.jar:3.2.7]
  at org.apache.dubbo.common.utils.ReflectUtils.forName(ReflectUtils.java:683) ~[dubbo-3.2.7.jar:3.2.7]
  ... 300 common frames omitted

Cause

org.apache.dubbo.rpc.protocol.tri.TripleInvoker#invokeUnary
When method descriptor is generic, it tries to find remote-defined-only class in client side, which causes the ClassNotFoundException.

if (methodDescriptor instanceof StubMethodDescriptor) {
  pureArgument = invocation.getArguments()[0];
} else {
  if (methodDescriptor.isGeneric()) {
      Object[] args = new Object[3];
      args[0] = RpcUtils.getMethodName(invocation);

      // here
      args[1] = Arrays.stream(RpcUtils.getParameterTypes(invocation)).map(Class::getName).toArray(String[]::new);

      args[2] = RpcUtils.getArguments(invocation);
      pureArgument = args;
  } else {
      pureArgument = invocation.getArguments();
  }
}
@hwding hwding added the type/bug Bugs to being fixed label Nov 29, 2023
AlbumenJ added a commit to AlbumenJ/dubbo-samples that referenced this issue Nov 30, 2023
AlbumenJ added a commit to apache/dubbo-samples that referenced this issue Dec 14, 2023
* Add test cases to verify apache/dubbo#13436

* Fix headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Bugs to being fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant