大数据开发中遇到的错误 java.lang.RuntimeException: java.io.IOException: invalid constant type: 18

版本打包时竟然遇到这种错误

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.RuntimeException: java.io.IOException: invalid constant type: 18
 at javassist.CtClassType.getClassFile2(CtClassType.java:204)
 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.CodeGen.doTypeCheck(CodeGen.java:242)
 at javassist.compiler.CodeGen.atStmnt(CodeGen.java:330)
 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)
 at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)
 at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
 at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
 at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:948)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: invalid constant type: 18
 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)
... 55 more

网上查了下解决方案,我在这里笔记一下


问题分析

1. 根据异常日志中dubbo调用javassist编译字节码出错,定位javassist版本问题;

2. 由于同样的dubbo项目在jdk6下没有问题,当前项目使用的jdk8,所以应该是jdk8和javassist冲突;

3. 将dubbo引入的javassist-3.15.0-GA去掉,引入更高版本直到javassist-3.18.0-GA项目可以正常启动。


解决步骤

1.把repository下的javassist3.18.1包删除
2.项目pom文件增加包


maven中需要增加的包:

   <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <version>2.8.4</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.20.0-GA</version>
   </dependency>



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值