javassist.CannotCompileException: [source error] no such class

本文介绍了一个关于javassist在与Dubbo集成时遇到的类找不到的问题,并详细解释了错误的原因及解决方法。主要原因是web应用的classLoader与javassist的classloader不一致导致。建议将jar包统一放置在标准目录下并注意类路径加载顺序。

场景:

javassist是动态代理用于生成字节码的一个开源组件,在web应用中与tomcat和weblogic等中间件集成的时候,遇到了这样的报错(报错在下面贴出)。

报错原因:

之所以报这个错,是因为web应用的classLoader与javassist的classloader不是同一个,那为什么不是同一个classLoader呢?一般的web应用部署到中间件时,都会把jar包放到\WEB-INF\lib的目录下,与WEB-INF\classes目录下的类文件是同一个classloader,但是我们公司在部署web应用的时候不是把jar包放到\WEB-INF\lib下,而是放到一个公共的地方。另外需要注意公共的lib目录和\WEB-INF\lib目录的classpath加载顺序,不要在两个目录都方javassist的jar包,否则也会出现同样的问题。


报错信息:


java.lang.RuntimeException: [source error] nosuch class: com.paic.pafademo.appdemo.web.dubbo.PafaACService

        atcom.alibaba.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:350)

        at com.alibaba.dubbo.common.bytecode.Wrapper.makeWrapper(Wrapper.java:346)

        at com.alibaba.dubbo.common.bytecode.Wrapper.getWrapper(Wrapper.java:89)

        atcom.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:426)

        at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281)

        Truncated. see log file for complete stacktrace

 

Caused By:javassist.CannotCompileException: [source error] no such class:com.paic.pafademo.appdemo.web.dubbo.PafaACService

        at javassist.CtNewMethod.make(CtNewMethod.java:79)

        at javassist.CtNewMethod.make(CtNewMethod.java:45)

        atcom.alibaba.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:318)

        at com.alibaba.dubbo.common.bytecode.Wrapper.makeWrapper(Wrapper.java:346)

        at com.alibaba.dubbo.common.bytecode.Wrapper.getWrapper(Wrapper.java:89)

        Truncated. see log file for complete stacktrace

 

Caused By: compile error: no such class:com.paic.pafademo.appdemo.web.dubbo.PafaACService

        at javassist.compiler.MemberResolver.searchImports(MemberResolver.java:448)

        at javassist.compiler.MemberResolver.lookupClass(MemberResolver.java:413)

        atjavassist.compiler.MemberResolver.lookupClassByJvmName(MemberResolver.java:331)

        at javassist.compiler.MemberResolver.resolveJvmClassName(MemberResolver.java:492)

        at javassist.compiler.MemberCodeGen.resolveClassName(MemberCodeGen.java:1147)

        Truncated. see log file for complete stacktrace

>

<2013-4-1 上午11时13分30秒 CST> <Error><Deployer> <BEA-149231> <Unable to set the activation state totrue for the application 'appdemo'.

weblogic.application.ModuleException:[HTTP:101216]Servlet: "dispatcher" failed to preload on startup inWeb application: "/appdemo".

java.lang.RuntimeException: [source error]no such class: com.paic.pafademo.appdemo.web.dubbo.PafaACService

        atcom.alibaba.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:350)

        at com.alibaba.dubbo.common.bytecode.Wrapper.makeWrapper(Wrapper.java:346)

        at com.alibaba.dubbo.common.bytecode.Wrapper.getWrapper(Wrapper.java:89)

        atcom.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:426)

        at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281)

        at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:242)

        at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:143)

        at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)

        atorg.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)

        atorg.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:324)

        atorg.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:929)

        atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:467)

        atorg.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)

        atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)

        atcom.paic.pafa.web.PafaDispatcherServlet.createWebApplicationContext(PafaDispatcherServlet.java:25)

        atorg.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)

        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)

        atorg.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)

        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)

        at javax.servlet.GenericServlet.init(GenericServlet.java:241)

        atweblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)

        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)

        atweblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)

        at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)

        atweblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)

        at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:531)

        atweblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1915)

        atweblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1889)

        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1807)

        atweblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3045)

        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1397)

        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:460)

        atweblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)

        atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)

        atweblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)

        at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)

        atweblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)

        atweblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)

        atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)

        atweblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)

        at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)

        atweblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:1267)

        atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)

        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:409)

        at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:54)

        atweblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)

        atweblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)

        atweblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)

        at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)

        atweblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)

        at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:196)

        atweblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)

        atweblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)

        at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)

        atweblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)

        at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)

        atweblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)

        at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)

        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)

        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

Caused by:javassist.CannotCompileException: [source error] no such class:com.paic.pafademo.appdemo.web.dubbo.PafaACService

        at javassist.CtNewMethod.make(CtNewMethod.java:79)

        at javassist.CtNewMethod.make(CtNewMethod.java:45)

        atcom.alibaba.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:318)

        ... 60 more

Caused by: compile error: no such class:com.paic.pafademo.appdemo.web.dubbo.PafaACService

        at javassist.compiler.MemberResolver.searchImports(MemberResolver.java:448)

        at javassist.compiler.MemberResolver.lookupClass(MemberResolver.java:413)

        at javassist.compiler.MemberResolver.lookupClassByJvmName(MemberResolver.java:331)

        atjavassist.compiler.MemberResolver.resolveJvmClassName(MemberResolver.java:492)

        at javassist.compiler.MemberCodeGen.resolveClassName(MemberCodeGen.java:1147)

        at javassist.compiler.CodeGen.atDeclarator(CodeGen.java:712)

        at javassist.compiler.ast.Declarator.accept(Declarator.java:100)

        at javassist.compiler.CodeGen.atStmnt(CodeGen.java:351)

        at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)

        at javassist.compiler.CodeGen.atStmnt(CodeGen.java:351)

        at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)

        at javassist.compiler.CodeGen.atMethodBody(CodeGen.java:292)

        at javassist.compiler.CodeGen.atMethodDecl(CodeGen.java:274)

        at javassist.compiler.ast.MethodDecl.accept(MethodDecl.java:44)

        at javassist.compiler.Javac.compileMethod(Javac.java:169)

        at javassist.compiler.Javac.compile(Javac.java:95)

        at javassist.CtNewMethod.make(CtNewMethod.java:74)

        ... 62 more

 

        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1399)

        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:460)

        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)

        atweblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)

        atweblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)

        Truncated. see log file for complete stacktrace

 

Caused By: compile error: no such class:com.paic.pafademo.appdemo.web.dubbo.PafaACService

        at javassist.compiler.MemberResolver.searchImports(MemberResolver.java:448)

        at javassist.compiler.MemberResolver.lookupClass(MemberResolver.java:413)

        atjavassist.compiler.MemberResolver.lookupClassByJvmName(MemberResolver.java:331)

        atjavassist.compiler.MemberResolver.resolveJvmClassName(MemberResolver.java:492)

        at javassist.compiler.MemberCodeGen.resolveClassName(MemberCodeGen.java:1147)

        Truncated. see log file for complete stacktrace


我弄好了,现在在弄这个,一、启动zookeeper服务和kafka服务 打开第1个终端,执行如下命令启动Zookeeper服务: cd /export/server/kafka ./bin/zookeeper-server-start.sh config/zookeeper.properties 打开第2个终端,执行如下命令启动Kafka服务: cd /export/server/kafka ./bin/kafka-server-start.sh config/server.properties 打开第3个终端,执行如下命令创建一个名为test的Topic: cd /export/server/kafka ./bin/kafka-topics.sh --create --topic test --bootstrap-server localhost:9092 二、创建配置文件nc_kafka.conf 在Flume安装目录的conf子目录下创建一个配置文件nc_kafka.conf,内容如下: # 设置Agent上的各个组件名称 a1.sources = r1 a1.sinks = k1 a1.channels = c1 # 配置Source a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 # 配置Sink a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink a1.sinks.k1.kafka.topic = test a1.sinks.k1.kafka.bootstrap.servers = localhost:9092 a1.sinks.k1.kafka.flumeBatchSize = 20 a1.sinks.k1.kafka.producer.acks = 1 a1.sinks.k1.kafka.producer.linger.ms = 1 a1.sinks.k1.kafka.producer.compression.type = snappy # 配置Channel a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 # 把Source和Sink绑定到Channel上 a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1 三、启动flume 打开第4个终端,执行如下命令启动Flume: cd /export/server/flume ./bin/flume-ng agent --conf ./conf --conf-file ./conf/nc_kafka.conf --name a1 -Dflume.root.logger=INFO,console 四、启动监听端口 打开第5个终端,执行如下命令: nc localhost 44444 执行上面的命令以后,在该窗口内用键盘输入一些单词,如“hadoop”。这个单词会发送给Flume,然后由Flume发送给Kafka。 五、启动kafka消费者 打开第6个终端,执行如下命令启动Kafka消费者: cd /export/server/kafka ./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning 上面的命令执行以后,就可以在屏幕上看到“hadoop”,说明Kafka成功接收到了数据。 六、报错 在这里插入图片描述 Kafka 2.6.0 内置依赖的 ZooKeeper 版本是 3.4.x(无 ZKClientConfig 构造方法),但系统中 3.9.2 的 ZK 包被优先加载,或 Kafka 尝试调用 3.5+ 版本的 ZK 方法,导致版本不兼容。 进入 Kafka 安装目录的 bin 目录,编辑 kafka-server-start.sh 步骤 1:彻底隔离 Kafka 与系统独立 ZK vim /export/server/kafka/bin/kafka-server-start.sh unset CLASSPATH KAFKA_HOME=“/export/server/kafka” CLASSPATH=“$KAFKA_HOME/libs/*” 步骤2:同理修改 ZK 启动脚本 vim /export/server/kafka/bin/zookeeper-server-start.sh unset CLASSPATH KAFKA_HOME=“/export/server/kafka/” CLASSPATH=“$KAFKA_HOME/libs/*”但是我遇到问题了.打开第2个终端,执行如下命令启动Kafka服务: cd /export/server/kafka ./bin/kafka-server-start.sh config/server.properties 连接主机... 连接主机成功 Last login: Mon Dec 29 12:39:29 2025 from 192.168.81.1 [ma@master ~]$ su 密码: [root@master ma]# cd /export/server/kafka [root@master kafka]# ./bin/kafka-server-start.sh config/server.properties [2025-12-29 13:12:28,429] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$) [2025-12-29 13:12:29,489] INFO Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation (org.apache.zookeeper.common.X509Util) [2025-12-29 13:12:29,602] INFO Registered signal handlers for TERM, INT, HUP (org.apache.kafka.common.utils.LoggingSignalHandler) [2025-12-29 13:12:29,610] INFO starting (kafka.server.KafkaServer) [2025-12-29 13:12:29,611] INFO Connecting to zookeeper on 192.168.81.130:2181,192.168.81.131:2181,192.168.81.132:2181 (kafka.server.KafkaServer) [2025-12-29 13:12:29,658] INFO [ZooKeeperClient Kafka server] Initializing a new session to 192.168.81.130:2181,192.168.81.131:2181,192.168.81.132:2181. (kafka.zookeeper.ZooKeeperClient) [2025-12-29 13:12:29,665] INFO Client environment:zookeeper.version=3.5.8-f439ca583e70862c3068a1f2a7d4d068eec33315, built on 05/04/2020 15:53 GMT (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,665] INFO Client environment:host.name=master (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,665] INFO Client environment:java.version=1.8.0_241 (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,683] INFO Client environment:java.vendor=Oracle Corporation (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,683] INFO Client environment:java.home=/export/server/jdk/jre (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,683] INFO Client environment:java.class.path=/export/server/kafka/bin/../libs/activation-1.1.1.jar:/export/server/kafka/bin/../libs/aopalliance-repackaged-2.5.0.jar:/export/server/kafka/bin/../libs/argparse4j-0.7.0.jar:/export/server/kafka/bin/../libs/audience-annotations-0.5.0.jar:/export/server/kafka/bin/../libs/commons-cli-1.4.jar:/export/server/kafka/bin/../libs/commons-lang3-3.8.1.jar:/export/server/kafka/bin/../libs/connect-api-2.6.0.jar:/export/server/kafka/bin/../libs/connect-basic-auth-extension-2.6.0.jar:/export/server/kafka/bin/../libs/connect-file-2.6.0.jar:/export/server/kafka/bin/../libs/connect-json-2.6.0.jar:/export/server/kafka/bin/../libs/connect-mirror-2.6.0.jar:/export/server/kafka/bin/../libs/connect-mirror-client-2.6.0.jar:/export/server/kafka/bin/../libs/connect-runtime-2.6.0.jar:/export/server/kafka/bin/../libs/connect-transforms-2.6.0.jar:/export/server/kafka/bin/../libs/hk2-api-2.5.0.jar:/export/server/kafka/bin/../libs/hk2-locator-2.5.0.jar:/export/server/kafka/bin/../libs/hk2-utils-2.5.0.jar:/export/server/kafka/bin/../libs/jackson-annotations-2.10.2.jar:/export/server/kafka/bin/../libs/jackson-core-2.10.2.jar:/export/server/kafka/bin/../libs/jackson-databind-2.10.2.jar:/export/server/kafka/bin/../libs/jackson-dataformat-csv-2.10.2.jar:/export/server/kafka/bin/../libs/jackson-datatype-jdk8-2.10.2.jar:/export/server/kafka/bin/../libs/jackson-jaxrs-base-2.10.2.jar:/export/server/kafka/bin/../libs/jackson-jaxrs-json-provider-2.10.2.jar:/export/server/kafka/bin/../libs/jackson-module-jaxb-annotations-2.10.2.jar:/export/server/kafka/bin/../libs/jackson-module-paranamer-2.10.2.jar:/export/server/kafka/bin/../libs/jackson-module-scala_2.12-2.10.2.jar:/export/server/kafka/bin/../libs/jakarta.activation-api-1.2.1.jar:/export/server/kafka/bin/../libs/jakarta.annotation-api-1.3.4.jar:/export/server/kafka/bin/../libs/jakarta.inject-2.5.0.jar:/export/server/kafka/bin/../libs/jakarta.ws.rs-api-2.1.5.jar:/export/server/kafka/bin/../libs/jakarta.xml.bind-api-2.3.2.jar:/export/server/kafka/bin/../libs/javassist-3.22.0-CR2.jar:/export/server/kafka/bin/../libs/javassist-3.26.0-GA.jar:/export/server/kafka/bin/../libs/javax.servlet-api-3.1.0.jar:/export/server/kafka/bin/../libs/javax.ws.rs-api-2.1.1.jar:/export/server/kafka/bin/../libs/jaxb-api-2.3.0.jar:/export/server/kafka/bin/../libs/jersey-client-2.28.jar:/export/server/kafka/bin/../libs/jersey-common-2.28.jar:/export/server/kafka/bin/../libs/jersey-container-servlet-2.28.jar:/export/server/kafka/bin/../libs/jersey-container-servlet-core-2.28.jar:/export/server/kafka/bin/../libs/jersey-hk2-2.28.jar:/export/server/kafka/bin/../libs/jersey-media-jaxb-2.28.jar:/export/server/kafka/bin/../libs/jersey-server-2.28.jar:/export/server/kafka/bin/../libs/jetty-client-9.4.24.v20191120.jar:/export/server/kafka/bin/../libs/jetty-continuation-9.4.24.v20191120.jar:/export/server/kafka/bin/../libs/jetty-http-9.4.24.v20191120.jar:/export/server/kafka/bin/../libs/jetty-io-9.4.24.v20191120.jar:/export/server/kafka/bin/../libs/jetty-security-9.4.24.v20191120.jar:/export/server/kafka/bin/../libs/jetty-server-9.4.24.v20191120.jar:/export/server/kafka/bin/../libs/jetty-servlet-9.4.24.v20191120.jar:/export/server/kafka/bin/../libs/jetty-servlets-9.4.24.v20191120.jar:/export/server/kafka/bin/../libs/jetty-util-9.4.24.v20191120.jar:/export/server/kafka/bin/../libs/jopt-simple-5.0.4.jar:/export/server/kafka/bin/../libs/kafka_2.12-2.6.0.jar:/export/server/kafka/bin/../libs/kafka_2.12-2.6.0-sources.jar:/export/server/kafka/bin/../libs/kafka-clients-2.6.0.jar:/export/server/kafka/bin/../libs/kafka-log4j-appender-2.6.0.jar:/export/server/kafka/bin/../libs/kafka-streams-2.6.0.jar:/export/server/kafka/bin/../libs/kafka-streams-examples-2.6.0.jar:/export/server/kafka/bin/../libs/kafka-streams-scala_2.12-2.6.0.jar:/export/server/kafka/bin/../libs/kafka-streams-test-utils-2.6.0.jar:/export/server/kafka/bin/../libs/kafka-tools-2.6.0.jar:/export/server/kafka/bin/../libs/log4j-1.2.17.jar:/export/server/kafka/bin/../libs/lz4-java-1.7.1.jar:/export/server/kafka/bin/../libs/maven-artifact-3.6.3.jar:/export/server/kafka/bin/../libs/metrics-core-2.2.0.jar:/export/server/kafka/bin/../libs/netty-buffer-4.1.50.Final.jar:/export/server/kafka/bin/../libs/netty-codec-4.1.50.Final.jar:/export/server/kafka/bin/../libs/netty-common-4.1.50.Final.jar:/export/server/kafka/bin/../libs/netty-handler-4.1.50.Final.jar:/export/server/kafka/bin/../libs/netty-resolver-4.1.50.Final.jar:/export/server/kafka/bin/../libs/netty-transport-4.1.50.Final.jar:/export/server/kafka/bin/../libs/netty-transport-native-epoll-4.1.50.Final.jar:/export/server/kafka/bin/../libs/netty-transport-native-unix-common-4.1.50.Final.jar:/export/server/kafka/bin/../libs/osgi-resource-locator-1.0.1.jar:/export/server/kafka/bin/../libs/paranamer-2.8.jar:/export/server/kafka/bin/../libs/plexus-utils-3.2.1.jar:/export/server/kafka/bin/../libs/reflections-0.9.12.jar:/export/server/kafka/bin/../libs/rocksdbjni-5.18.4.jar:/export/server/kafka/bin/../libs/scala-collection-compat_2.12-2.1.6.jar:/export/server/kafka/bin/../libs/scala-java8-compat_2.12-0.9.1.jar:/export/server/kafka/bin/../libs/scala-library-2.12.11.jar:/export/server/kafka/bin/../libs/scala-logging_2.12-3.9.2.jar:/export/server/kafka/bin/../libs/scala-reflect-2.12.11.jar:/export/server/kafka/bin/../libs/slf4j-api-1.7.30.jar:/export/server/kafka/bin/../libs/slf4j-log4j12-1.7.30.jar:/export/server/kafka/bin/../libs/snappy-java-1.1.7.3.jar:/export/server/kafka/bin/../libs/validation-api-2.0.1.Final.jar:/export/server/kafka/bin/../libs/zookeeper-3.5.8.jar:/export/server/kafka/bin/../libs/zookeeper-jute-3.5.8.jar:/export/server/kafka/bin/../libs/zstd-jni-1.4.4-7.jar (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:os.arch=amd64 (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:os.version=3.10.0-1160.71.1.el7.x86_64 (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:user.dir=/export/server/kafka (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:os.memory.free=978MB (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:os.memory.max=1024MB (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,684] INFO Client environment:os.memory.total=1024MB (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,688] INFO Initiating client connection, connectString=192.168.81.130:2181,192.168.81.131:2181,192.168.81.132:2181 sessionTimeout=18000 watcher=kafka.zookeeper.ZooKeeperClient$ZooKeeperClientWatcher$@15ff3e9e (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:29,693] INFO jute.maxbuffer value is 4194304 Bytes (org.apache.zookeeper.ClientCnxnSocket) [2025-12-29 13:12:29,701] INFO zookeeper.request.timeout value is 0. feature enabled= (org.apache.zookeeper.ClientCnxn) [2025-12-29 13:12:29,704] INFO [ZooKeeperClient Kafka server] Waiting until connected. (kafka.zookeeper.ZooKeeperClient) [2025-12-29 13:12:29,738] INFO Opening socket connection to server master/192.168.81.130:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn) [2025-12-29 13:12:29,743] INFO Socket connection established, initiating session, client: /192.168.81.130:47500, server: master/192.168.81.130:2181 (org.apache.zookeeper.ClientCnxn) [2025-12-29 13:12:29,797] INFO Session establishment complete on server master/192.168.81.130:2181, sessionid = 0x100003fd9530000, negotiated timeout = 18000 (org.apache.zookeeper.ClientCnxn) [2025-12-29 13:12:29,812] INFO [ZooKeeperClient Kafka server] Connected. (kafka.zookeeper.ZooKeeperClient) [2025-12-29 13:12:30,517] INFO Cluster ID = 2YN4O8VMRUaIXugHr0HZtA (kafka.server.KafkaServer) [2025-12-29 13:12:30,531] ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer) kafka.common.InconsistentClusterIdException: The Cluster ID 2YN4O8VMRUaIXugHr0HZtA doesn't match stored clusterId Some(rXq3CjVORJCOrQ2Jdh_KQg) in meta.properties. The broker is trying to join the wrong cluster. Configured zookeeper.connect may be wrong. at kafka.server.KafkaServer.startup(KafkaServer.scala:235) at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:44) at kafka.Kafka$.main(Kafka.scala:82) at kafka.Kafka.main(Kafka.scala) [2025-12-29 13:12:30,539] INFO shutting down (kafka.server.KafkaServer) [2025-12-29 13:12:30,554] INFO [ZooKeeperClient Kafka server] Closing. (kafka.zookeeper.ZooKeeperClient) [2025-12-29 13:12:30,660] INFO Session: 0x100003fd9530000 closed (org.apache.zookeeper.ZooKeeper) [2025-12-29 13:12:30,662] INFO [ZooKeeperClient Kafka server] Closed. (kafka.zookeeper.ZooKeeperClient) [2025-12-29 13:12:30,663] INFO EventThread shut down for session: 0x100003fd9530000 (org.apache.zookeeper.ClientCnxn) [2025-12-29 13:12:30,667] INFO shut down completed (kafka.server.KafkaServer) [2025-12-29 13:12:30,667] ERROR Exiting Kafka. (kafka.server.KafkaServerStartable) [2025-12-29 13:12:30,674] INFO shutting down (kafka.server.KafkaServer) [root@master kafka]# 打开第3个终端,执行如下命令创建一个名为test的Topic: cd /export/server/kafka ./bin/kafka-topics.sh --create --topic test --bootstrap-server localhost:9092 连接主机... 连接主机成功 Last login: Mon Dec 29 12:39:32 2025 from 192.168.81.1 [ma@master ~]$ su 密码: [root@master ma]# cd /export/server/kafka [root@master kafka]# ./bin/kafka-topics.sh --create --topic test --bootstrap-server localhost:909 [2025-12-29 13:12:43,484] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:43,605] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:43,706] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:44,009] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:44,414] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:45,222] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:46,228] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:47,341] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:48,356] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:49,266] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:50,283] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:51,195] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:52,305] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:53,524] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:54,637] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:55,859] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:57,068] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:58,078] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:12:58,991] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:00,201] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:01,313] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:02,225] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:03,230] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:04,340] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:05,456] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:06,464] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:07,471] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:08,688] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:09,901] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:10,815] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:11,934] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:12,944] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:14,118] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:15,232] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:16,139] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:17,148] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:18,164] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:19,375] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:20,294] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:21,207] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:22,416] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:23,525] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:24,643] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:25,650] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:26,868] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:27,674] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:28,883] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:29,790] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:30,821] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:31,932] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:32,957] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:33,965] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:34,971] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:35,897] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:36,802] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:37,812] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:38,825] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:40,041] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:41,050] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:42,259] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2025-12-29 13:13:43,368] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:909) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) Error while executing topic command : Call(callName=createTopics, deadlineMs=1766985223498, tries=1, nextAllowedTryMs=1766985223603) timed out at 1766985223503 after 1 attempt(s) [2025-12-29 13:13:43,509] ERROR org.apache.kafka.common.errors.TimeoutException: Call(callName=createTopics, deadlineMs=1766985223498, tries=1, nextAllowedTryMs=1766985223603) timed out at 1766985223503 after 1 attempt(s) Caused by: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. (kafka.admin.TopicCommand$) [root@master kafka]#
最新发布
12-30
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值