使用spring和dubbo报错:Error creating bean with name 'com.gsyshop.service.ItemService':

1.spring版本和dubbo版本由maven管理,jdk12 tomcat9 dubbo部署在linux服务器上 可以跑起来。版本详细配置如图
图片说明

2.启动服务层工程时报错信息如下:

2019-09-21 01:43:41 [ERROR] -ContextLoader.java(353) -Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.gsyshop.service.ItemService': Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.ExceptionInInitializerError
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098)
    ... 22 more
Caused by: java.lang.IllegalStateException: fail to create adaptive instance: java.lang.IllegalStateException: Can not create adaptive extenstion interface com.alibaba.dubbo.rpc.Protocol, cause: java.io.IOException: invalid constant type: 18
    at com.alibaba.dubbo.common.extension.ExtensionLoader.getAdaptiveExtension(ExtensionLoader.java:459)
    at com.alibaba.dubbo.config.ServiceConfig.<clinit>(ServiceConfig.java:60)
    ... 30 more
Caused by: java.lang.IllegalStateException: Can not create adaptive extenstion interface com.alibaba.dubbo.rpc.Protocol, cause: java.io.IOException: invalid constant type: 18
    at com.alibaba.dubbo.common.extension.ExtensionLoader.createAdaptiveExtension(ExtensionLoader.java:723)
    at com.alibaba.dubbo.common.extension.ExtensionLoader.getAdaptiveExtension(ExtensionLoader.java:455)
    ... 31 more
Caused by: 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.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.MemberCodeGen.atMethodCallCore(MemberCodeGen.java:562)
    at javassist.compiler.MemberCodeGen.atCallExpr(MemberCodeGen.java:524)
    at javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:244)
    at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
    at javassist.compiler.MemberCodeGen.atCallExpr(MemberCodeGen.java:497)
    at javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:244)
    at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
    at javassist.compiler.MemberCodeGen.atCallExpr(MemberCodeGen.java:497)
    at javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:244)
    at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
    at javassist.compiler.MemberCodeGen.atCallExpr(MemberCodeGen.java:497)
    at javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:244)
    at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
    at javassist.compiler.CodeGen.atBinExpr(CodeGen.java:964)
    at javassist.compiler.ast.BinExpr.accept(BinExpr.java:41)
    at javassist.compiler.JvstCodeGen.atMethodArgs(JvstCodeGen.java:358)
    at javassist.compiler.MemberCodeGen.atMethodCallCore(MemberCodeGen.java:556)
    at javassist.compiler.MemberCodeGen.atNewExpr(MemberCodeGen.java:302)
    at javassist.compiler.ast.NewExpr.accept(NewExpr.java:73)
    at javassist.compiler.CodeGen.compileExpr(CodeGen.java:230)
    at javassist.compiler.CodeGen.atThrowStmnt(CodeGen.java:628)
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:365)
    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.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.compiler.support.JavassistCompiler.doCompile(JavassistCompiler.java:119)
    at com.alibaba.dubbo.common.compiler.support.AbstractCompiler.compile(AbstractCompiler.java:59)
    at com.alibaba.dubbo.common.compiler.support.AdaptiveCompiler.compile(AdaptiveCompiler.java:46)
    at com.alibaba.dubbo.common.extension.ExtensionLoader.createAdaptiveExtensionClass(ExtensionLoader.java:739)
    at com.alibaba.dubbo.common.extension.ExtensionLoader.getAdaptiveExtensionClass(ExtensionLoader.java:732)
    at com.alibaba.dubbo.common.extension.ExtensionLoader.createAdaptiveExtension(ExtensionLoader.java:721)
    ... 32 more
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)
    ... 77 more
9月 21, 2019 1:43:41 上午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.gsyshop.service.ItemService': Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError

3.尝试方法:更换dubbo版本 2. 5 2.6 均不行

4.服务层和web层的dubbo配置如下;
服务层.xml

图片说明

web.xml
图片说明

2个回答

从Caused by: java.lang.IllegalStateException: Can not create adaptive extenstion interface com.alibaba.dubbo.rpc.Protocol, cause: java.io.IOException: invalid constant type: 18异常定位,有可能是javassit版本有冲突或者用了低版本,可以检查下,如有多个版本删除低的或者升级高的版本。

qq_30145831
健身coder 好的谢谢,我尝试把dubbo改成2.5.7 它引用的javassit变成了3.20版本 就不会报这个错误了,谢谢!
11 个月之前 回复
qq_30145831
健身coder 谢谢,我的zookeeper是部署在远程linux服务器上了 版本是zookeeper-3.4.6.tar.gz,这个和我在本地启动报无法创建bean有关系吗
11 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐