前言
一个阳光明媚的上午,临近午饭,收到了一个邮件。
开始纠结吃还是不吃的问题,当然本着职业操守,那肯定是要先吃饭的,不过看着提示还是挺简单的,就直接给jar 包,maven 文件进行了修改升级,行云流水,一顿操作猛如虎,打包,上传,部署,一气呵成。开开心心吃饭去了。
启动报错
吃完饭回来发现这个项目没有启动成功,本身这个服务是测试环境的,之前也是有问题一直是瘫痪的状态,所以感受不是很直观。正好还有其他问题,就暂且放过了这个事儿。
结果组长来说,你这得启动成功啊,不成功不算是解决漏洞,还需要回复邮件,那就刚一波吧。说实话,公司这个项目使用tomcat 容器进行运行而不是直接使用spring boot 我真的是头疼。还有就是对tomcat 的使用已经是很遥远的记忆了,虽然spring boot 内部也是使用
项目情况
spring 4.2.2
dubbo 2.7.7
看下报错内容
28-Feb-2022 17:54:38.348 SEVERE [startStop-1] 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 'referenceAnnotationBeanPostProcessor': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.setClassValuesAsString(Z)V 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:305) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:201) at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:207) at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:683) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:522) 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:4699) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5165) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1412) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1402) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.setClassValuesAsString(Z)V at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163) 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.NoSuchMethodError: org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.setClassValuesAsString(Z)V at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.<init>(ReferenceAnnotationBeanPostProcessor.java:106) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
贴个类似的问题及解决方案
https://github.com/alibaba/spring-cloud-alibaba/issues/2310
可以对照alibaba 给出的版本对应表进行构建项目
https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E
实践操作
通过maven 仓库检查dubbo-2.7.15的相关依赖
https://mvnrepository.com/artifact/org.apache.dubbo/dubbo/2.7.15
通过相同的方式看该jar 包还需要什么,进行对项目的引入。打包,构建,上传,部署,还是出现了上面的报错。准备继续在https://github.com/apache/dubbo/issues/9494
dubbo 的git hub 仓库里溜达溜达。
坚持不懈,大家加油!!!