Today, the project upgraded from Jdk7 to Jdk8,tomcat started with this run-time error.
error message: Java.io.IOException:invalid constant type:18
2015-09-17 09:06:16:error localhost-startstop-1 Org.springframework.web.context.contextloader-context Initialization failed Java.lang.RuntimeException:java.io.IOException:invalid constant type:18 at javassist. Ctclasstype.getclassfile2 (ctclasstype.java:203) at Javassist. Ctclasstype.subtypeof (ctclasstype.java:303) at Javassist. Ctclasstype.subtypeof (ctclasstype.java:318) at Javassist.compiler.MemberResolver.compareSignature ( memberresolver.java:247) at Javassist.compiler.MemberResolver.lookupMethod (memberresolver.java:119) at Javassist.compiler.MemberResolver.lookupMethod (memberresolver.java:96) at Javassist.compiler.TypeChecker.atMethodCallCore (typechecker.java:704) at JAVASSIST.COMPILER.TYPECHECKER.ATCALLEXPR (typechecker.java:681) at javassist.compiler.JvstTypeChecker.atCallExpr (jvsttypechecker.java:156) at Javassist.compiler.ast.CallExpr.accept (callexpr.java:45) at Javassist.compiler.JvstTypeChecker.atCastToWrapper (jvsttypechecker.java:125) at JAVASSIST.COMPILER.JVSTTYPECHECKER.ATCASTEXPR (jvsttypechecker.java:97) at Javassist.compiler.ast.CastExpr.accept (castexpr.java:54) at Javassist.compiler.CodeGen.doTypeCheck (codegen.java:241) at javassist.compiler.CodeGen.compileExpr (Codegen.java : 228) at Javassist.compiler.CodeGen.atReturnStmnt2 (codegen.java:597) at Javassist.compiler.JvstCodeGen.atReturnStmnt (jvstcodegen.java:424) at Javassist.compiler.CodeGen.atStmnt ( codegen.java:362) at Javassist.compiler.ast.Stmnt.accept (stmnt.java:49) at Javassist.compiler.CodeGen.atStmnt ( codegen.java:350) at Javassist.compiler.ast.Stmnt.accept (stmnt.java:49) at Javassist.compiler.CodeGen.atIfStmnt ( codegen.java:390) at Javassist.compiler.CodeGen.atStmnt (codegen.java:354) at Javassist.compiler.ast.Stmnt.accept ( stmnt.java:49) at Javassist.compiler.CodeGen.atStmnt (codegen.java:350) at Javassist.compiler.ast.Stmnt.accept ( stmnt.java:49) at Javassist.compiler.MemberCodeGen.atTryStmnt (membercodegen.java:203) at
Javassist.compiler.CodeGen.atStmnt (codegen.java:366)At Javassist.compiler.ast.Stmnt.accept (stmnt.java:49) at Javassist.compiler.CodeGen.atStmnt (codegen.java:350) at
Javassist.compiler.ast.Stmnt.accept (stmnt.java:49) at Javassist.compiler.CodeGen.atMethodBody (codegen.java:291) At Javassist.compiler.CodeGen.atMethodDecl (codegen.java:273) at Javassist.compiler.ast.MethodDecl.accept ( methoddecl.java:43) at Javassist.compiler.Javac.compileMethod (javac.java:168) at Javassist.compiler.Javac.compile ( javac.java:94) at Javassist. Ctnewmethod.make (ctnewmethod.java:73) at Javassist. Ctnewmethod.make (ctnewmethod.java:44) 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:97) at Org.springframework.context.support.AbstractApplicationContext.publishEvent (Abstractapplicationcontext.java : 327) at Org.springframework.context.support.AbstractApplicationContext.finishRefresh ( abstractapplicationcontext.java:941) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:475) at
Org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext (contextloader.java:388) At Org.springframework.web.context.ContextLoader.initWebApplicationContext (contextloader.java:293) at Org.springframework.web.context.ContextLoaderListener.contextInitialized (Contextloaderlistener.java:111) at Org.apache.catalina.core.StandardContext.listenerStart (standardcontext.java:5003) at Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5517) at Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:150) at Org.apache.catalina.core.ContainerBase.addChildInternal (containerbase.java:901) at Org.apache.catalina.core.ContainerBase.addChild (containerbase.java:877) at Org.apache.catalina.core.StandardHost.addChild (standardhost.java:652) at Org.apache.catalina.startup.HostConfig.deployWAR (hostconfig.java:1095) at Org.apache.catalina.startup.HostConfig
$DeployWar. Run (hostconfig.java:1930) at Java.util.concurrent.executors$runnableadapter.call (executors.java:511) 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:1090) at Javassist.bytecode.ConstPool.read (constpool.java:1033) at javassist.bytecode.constpool.<init> ( constpool.java:149) at Javassist.bytecode.ClassFile.read (classfile.java:737) at javassist.bytecode.classfile.< Init> (classfile.java:108) at Javassist. Ctclasstype.getclassfile2 (ctclasstype.java:190) ... More
Workaround:
Online Check Some people say is javassist3.18.1 the following version in the JDK8 version does not work, and I use the version is 3.12.1, decisively replaced to 3.18.1 version, start still not.
Another netizen said ASM5 the following version does not work under JDK8, and another class library that has stopped updating Cglib, its latest version 3.0 can only support to ASM4,
So the Final solution is: delete cglib, ASM upgrade to 5.0.4, javassist upgrade to 3.18.0 above, test successful.
Related Class Library introduction: ASM is a Java byte-code manipulation framework. It can modify an existing class or dynamically generate a class in binary form.
ASM can directly produce binary class files, or it can dynamically change class behavior before the class is loaded into the Java virtual machine.
After reading the information from the class file, ASM can change the class behavior, analyze the class information, and even generate the new class according to the user's request.
The Cglib (Code Generation Library) dynamically generates the implementation classes of interfaces and subclasses that inherit from a class while the program is running, depending on the ASM.
Javassist is an Open-source class library that analyzes, edits, and creates Java bytecode, dynamically altering the structure of classes, or dynamically generating classes.
Currently Cglib has stopped updating, Javassist has replaced the Cglib function.