原因:java.lang.classnotfoundexception:io.confluent.monitoring.clients.interceptor.monitoringproducerinterceptor

pqwbnv8z  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(373)

尝试通过合流平台使用rest proxy将消息发布到kafka主题,并使用以下错误进行响应
请求:

  1. $ curl -X POST -H "Content-Type: application/vnd.kafka.avro.v2+json" \
  2. -H "Accept: application/vnd.kafka.v2+json" \
  3. --data '{"value_schema": "{\"type\": \"record\", \"name\": \"User\", \"fields\": [{\"name\": \"name\", \"type\": \"string\"}]}", "records": [{"value": {"name": "test name"}}]}' \
  4. "http://${RESTPROXY_HOST}:8082/topics/${TOPIC}"

答复:

  1. {"error_code":500,"message":"Internal Server Error"}

错误日志来自./kafka rest/logs/kafka-rest.log

  1. [2018-08-06 14:29:00,734] INFO [Producer clientId=producer-4] Closing the Kafka producer with timeoutMillis = 0 ms. (org.apache.kafka.clients.producer.KafkaProducer)
  2. [2018-08-06 14:29:00,734] ERROR Unhandled exception resulting in internal server error response (io.confluent.rest.exceptions.GenericExceptionMapper)
  3. java.lang.reflect.UndeclaredThrowableException
  4. at com.sun.proxy.$Proxy12.getProducerPool(Unknown Source)
  5. at io.confluent.kafkarest.resources.TopicsResource.produce(TopicsResource.java:147)
  6. at io.confluent.kafkarest.resources.TopicsResource.produceAvro(TopicsResource.java:135)
  7. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  8. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  9. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  10. at java.lang.reflect.Method.invoke(Method.java:498)
  11. at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
  12. at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
  13. at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
  14. at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:143)
  15. at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
  16. at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
  17. at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
  18. at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
  19. at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
  20. at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
  21. at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
  22. at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
  23. at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
  24. at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
  25. at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
  26. at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
  27. at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
  28. at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
  29. at org.glassfish.jersey.servlet.ServletContainer.serviceImpl(ServletContainer.java:408)
  30. at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:583)
  31. at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:524)
  32. at org.glassfish.jersey.servlet.ServletContainer.doFilter(ServletContainer.java:461)
  33. at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
  34. at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
  35. at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
  36. at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
  37. at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
  38. at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
  39. at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
  40. at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
  41. at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
  42. at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
  43. at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:159)
  44. at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
  45. at org.eclipse.jetty.server.Server.handle(Server.java:499)
  46. at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
  47. at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
  48. at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
  49. at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
  50. at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
  51. at java.lang.Thread.run(Thread.java:748)
  52. Caused by: java.lang.reflect.InvocationTargetException
  53. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  54. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  55. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  56. at java.lang.reflect.Method.invoke(Method.java:498)
  57. at io.confluent.kafkarest.extension.ContextInvocationHandler.invoke(ContextInvocationHandler.java:33)
  58. ... 48 more
  59. Caused by: org.apache.kafka.common.KafkaException: Failed to construct kafka producer
  60. at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:459)
  61. at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:289)
  62. at io.confluent.kafkarest.ProducerPool.buildNoSchemaProducer(ProducerPool.java:109)
  63. at io.confluent.kafkarest.ProducerPool.buildBinaryProducer(ProducerPool.java:95)
  64. at io.confluent.kafkarest.ProducerPool.<init>(ProducerPool.java:68)
  65. at io.confluent.kafkarest.ProducerPool.<init>(ProducerPool.java:57)
  66. at io.confluent.kafkarest.ProducerPool.<init>(ProducerPool.java:50)
  67. at io.confluent.kafkarest.DefaultKafkaRestContext.getProducerPool(DefaultKafkaRestContext.java:70)
  68. ... 53 more
  69. Caused by: org.apache.kafka.common.KafkaException: io.confluent.monitoring.clients.interceptor.MonitoringProducerInterceptor ClassNotFoundException exception occurred
  70. at org.apache.kafka.common.config.AbstractConfig.getConfiguredInstances(AbstractConfig.java:357)
  71. at org.apache.kafka.common.config.AbstractConfig.getConfiguredInstances(AbstractConfig.java:332)
  72. at org.apache.kafka.common.config.AbstractConfig.getConfiguredInstances(AbstractConfig.java:319)
  73. at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:380)
  74. ... 60 more
  75. Caused by: java.lang.ClassNotFoundException: io.confluent.monitoring.clients.interceptor.MonitoringProducerInterceptor
  76. at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
  77. at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  78. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
  79. at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  80. at java.lang.Class.forName0(Native Method)
  81. at java.lang.Class.forName(Class.java:348)
  82. at org.apache.kafka.common.utils.Utils.loadClass(Utils.java:322)
  83. at org.apache.kafka.common.utils.Utils.newInstance(Utils.java:311)
  84. at org.apache.kafka.common.config.AbstractConfig.getConfiguredInstances(AbstractConfig.java:355)
  85. ... 63 more
wribegjk

wribegjk1#

io.confluent.monitoring.clients.interceptor.MonitoringProducerInterceptor 类不存在于kafka rest代理类路径中。

放置 monitoring-interceptors.jar 在kafka rest proxy中(或者哪个融合服务由于这个错误而失败),classpath应该解决这个问题

细节

这个jar可以在当地商店找到 $CONFLUENT_HOME/share/java/monitoring-interceptors/monitoring-interceptors-*.jar 或合并maven回购与 group: "io.confluent", artifact: "monitoring-interceptors", version: "4.1.0" ```
$ cd $CONFLUENT_HOME
$ cp ./share/java/monitoring-interceptors/monitoring-interceptors-4.1.0.jar
./share/java/kafka-rest/

$ ./bin/confluent stop kafka-rest
$ ./bin/confluent start kafka-rest

展开查看全部

相关问题