apache / pulsar

Apache Pulsar - distributed pub-sub messaging system
https://pulsar.apache.org/
Apache License 2.0
14.25k stars 3.58k forks source link

Admin java sdk can't use BrokerStats.getLoadReport method #15167

Open WillsonYip opened 2 years ago

WillsonYip commented 2 years ago

Describe the bug

Admin java sdk can't use BrokerStats.getLoadReport method . Below is environment

os: win 10 java: 1.8

maven

  <dependency>
      <groupId>org.apache.pulsar</groupId>
      <artifactId>pulsar-client-admin</artifactId>
      <version>2.9.2</version>
  </dependency>

here is the code

try( PulsarAdmin admin = PulsarAdmin.builder()
        .serviceHttpUrl(url)
        .build()) {

    BrokerStats brokerStats = admin.brokerStats();

    System.out.println(brokerStats.getLoadReportAsync().get());

} catch (Exception e) {
   e.printStackTrace();
}

exception:

java.util.concurrent.ExecutionException: org.apache.pulsar.client.admin.PulsarAdminException: java.lang.TypeNotPresentException: Type org.apache.pulsar.shade.org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport not present
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
    at com.pulsar.service.impl.BrokerServiceImpl.main(BrokerServiceImpl.java:94)
Caused by: org.apache.pulsar.client.admin.PulsarAdminException: java.lang.TypeNotPresentException: Type org.apache.pulsar.shade.org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport not present
    at org.apache.pulsar.client.admin.internal.BaseResource.getApiException(BaseResource.java:247)
    at org.apache.pulsar.client.admin.internal.BrokerStatsImpl$5.failed(BrokerStatsImpl.java:210)
    at org.apache.pulsar.shade.org.glassfish.jersey.client.JerseyInvocation.submit(JerseyInvocation.java:908)
    at org.apache.pulsar.shade.org.glassfish.jersey.client.JerseyInvocation.submit(JerseyInvocation.java:800)
    at org.apache.pulsar.shade.org.glassfish.jersey.client.JerseyInvocation$AsyncInvoker.method(JerseyInvocation.java:614)
    at org.apache.pulsar.shade.org.glassfish.jersey.client.CompletableFutureAsyncInvoker.get(CompletableFutureAsyncInvoker.java:30)
    at org.apache.pulsar.shade.org.glassfish.jersey.client.CompletableFutureAsyncInvoker.get(CompletableFutureAsyncInvoker.java:26)
    at org.apache.pulsar.client.admin.internal.BaseResource.asyncGetRequest(BaseResource.java:165)
    at org.apache.pulsar.client.admin.internal.BrokerStatsImpl.getLoadReportAsync(BrokerStatsImpl.java:201)
    ... 1 more
Caused by: java.lang.TypeNotPresentException: Type org.apache.pulsar.shade.org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport not present
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:108)
    at java.lang.Class.getGenericInterfaces(Class.java:913)
    at org.apache.pulsar.shade.org.glassfish.jersey.internal.util.ReflectionHelper.getClass(ReflectionHelper.java:1085)
    at org.apache.pulsar.shade.org.glassfish.jersey.internal.util.ReflectionHelper.getClass(ReflectionHelper.java:1081)
    at org.apache.pulsar.shade.org.glassfish.jersey.client.JerseyInvocation.submit(JerseyInvocation.java:823)
    ... 7 more
Caused by: java.lang.ClassNotFoundException: org.apache.pulsar.shade.org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
    ... 17 more
WillsonYip commented 2 years ago

o. I found pulsar-client-admin-original can solve problem. so ignore me

shibd commented 2 years ago

According to the official website description, we do not need to specifically refer to the dependencies of original. pulsar-client-admin includes pulsar-client-admin-original. I had the same problem, and I use pulsar-client-all same reproduce.

https://pulsar.apache.org/docs/en/client-libraries-java/

WillsonYip commented 2 years ago

OK . I reopen this issue.

github-actions[bot] commented 2 years ago

The issue had no activity for 30 days, mark with Stale label.

github-actions[bot] commented 2 years ago

The issue had no activity for 30 days, mark with Stale label.