严重: Servlet [springDispatcher] in web application [/dubbo-service] threw load() exception java.io.IOException: invalid constant type: 15 at javassist.bytecode.ConstPool.readOne(ConstPool.java:1113) at javassist.bytecode.ConstPool.read(ConstPool.java:1056) at javassist.bytecode.ConstPool.<init>(ConstPool.java:150) at javassist.bytecode.ClassFile.read(ClassFile.java:765) at javassist.bytecode.ClassFile.<init>(ClassFile.java:109) at javassist.CtClassType.getClassFile2(CtClassType.java:191) at javassist.CtClassType.subtypeOf(CtClassType.java:304) at javassist.CtClassType.subtypeOf(CtClassType.java:319) at javassist.compiler.MemberResolver.compareSignature(MemberResolver.java:248) at javassist.compiler.MemberResolver.lookupMethod(MemberResolver.java:120) at javassist.compiler.MemberResolver.lookupMethod(MemberResolver.java:97) at javassist.compiler.TypeChecker.atMethodCallCore(TypeChecker.java:711) at javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:688) at javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:157) at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46) at javassist.compiler.JvstTypeChecker.atCastToWrapper(JvstTypeChecker.java:126) at javassist.compiler.JvstTypeChecker.atCastExpr(JvstTypeChecker.java:98) at javassist.compiler.ast.CastExpr.accept(CastExpr.java:55) at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:242) at javassist.compiler.CodeGen.compileExpr(CodeGen.java:229) at javassist.compiler.CodeGen.atReturnStmnt2(CodeGen.java:598) at javassist.compiler.JvstCodeGen.atReturnStmnt(JvstCodeGen.java:425) at javassist.compiler.CodeGen.atStmnt(CodeGen.java:363) 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.atIfStmnt(CodeGen.java:391) at javassist.compiler.CodeGen.atStmnt(CodeGen.java:355) 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.MemberCodeGen.atTryStmnt(MemberCodeGen.java:204) at javassist.compiler.CodeGen.atStmnt(CodeGen.java:367) 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) at javassist.CtNewMethod.make(CtNewMethod.java:45) at com.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) at com.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)
启动dubbo项目报错如上,原因为:
dubbo2.5.3版本调用javassist编译字节码出错,项目中使用的是jdk1.8,判断为javassist版本问题,将依赖javassist-3.15.0-GA去掉,引入更高版本直到javassist-3.21.0-GA。
<dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.21.0-GA</version> </dependency>
<dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>2.5.3</version> <exclusions> <exclusion> <artifactId>spring</artifactId> <groupId>org.springframework</groupId> </exclusion> <exclusion> <artifactId>javassist</artifactId> <groupId>org.javassist</groupId> </exclusion> </exclusions> </dependency>