项目

一般

简介

V10 com/fasterxml/jackson/databind和com/fasterxml/jackson/core 的jackson的冲突问题

由 黄 俊睿 在 大约 3 年 之前添加

异常信息:

ERROR [AutoDeployer] SpringApplication:834 - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'integrationArgumentResolverMessageConverter': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter]: Constructor threw exception; nested exception is java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    com/fasterxml/jackson/databind/cfg/MapperBuilder.streamFactory()Lcom/fasterxml/jackson/core/TokenStreamFactory; @7: areturn
  Reason:
    Type 'com/fasterxml/jackson/core/JsonFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/TokenStreamFactory' (from method signature)
  Current Frame:
    bci: @7
    flags: { }
    locals: { 'com/fasterxml/jackson/databind/cfg/MapperBuilder' }
    stack: { 'com/fasterxml/jackson/core/JsonFactory' }
  Bytecode:
    0x0000000: 2ab4 0002 b600 08b0                    

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1323) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1218) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755) ~[spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:402) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:173) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:153) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:95) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172) [spring-web-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:5681) [aas-web-core.jar:?]
    at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:600) [aas-web-glue.jar:?]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5577) [aas-web-core.jar:?]
    at com.sun.enterprise.web.WebModule.start(WebModule.java:517) [aas-web-glue.jar:?]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:885) [aas-web-core.jar:?]
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:868) [aas-web-core.jar:?]
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:644) [aas-web-core.jar:?]
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2032) [aas-web-glue.jar:?]
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1678) [aas-web-glue.jar:?]
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:83) [aas-web-glue.jar:?]
    at com.apusic.aas.internal.data.EngineRef.start(EngineRef.java:98) [aas-internal-api.jar:?]
    at com.apusic.aas.internal.data.ModuleInfo.start(ModuleInfo.java:267) [aas-internal-api.jar:?]
    at com.apusic.aas.internal.data.ApplicationInfo.start(ApplicationInfo.java:358) [aas-internal-api.jar:?]
    at com.apusic.enterprise.v10.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:479) [aas-kernel.jar:?]
    at com.apusic.enterprise.v10.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:197) [aas-kernel.jar:?]
    at com.apusic.aas.deployment.admin.DeployCommand.execute(DeployCommand.java:492) [aas-deployment-admin.jar:?]
    at com.apusic.enterprise.v10.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:518) [aas-kernel.jar:?]
    at com.apusic.enterprise.v10.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:514) [aas-kernel.jar:?]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_172]
    at javax.security.auth.Subject.doAs(Subject.java:360) [?:1.8.0_172]
    at com.apusic.enterprise.v10.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:513) [aas-kernel.jar:?]
    at com.apusic.enterprise.v10.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:544) [aas-kernel.jar:?]
    at com.apusic.enterprise.v10.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:536) [aas-kernel.jar:?]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_172]
    at javax.security.auth.Subject.doAs(Subject.java:360) [?:1.8.0_172]
    at com.apusic.enterprise.v10.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:535) [aas-kernel.jar:?]
    at com.apusic.enterprise.v10.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1443) [aas-kernel.jar:?]
    at com.apusic.enterprise.v10.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:88) [aas-kernel.jar:?]
    at com.apusic.enterprise.v10.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1825) [aas-kernel.jar:?]
    at com.apusic.aas.deployment.autodeploy.AutoOperation.run(AutoOperation.java:140) [aas-deployment-autodeploy.jar:?]
    at com.apusic.aas.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:574) [aas-deployment-autodeploy.jar:?]
    at com.apusic.aas.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:461) [aas-deployment-autodeploy.jar:?]
    at com.apusic.aas.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:388) [aas-deployment-autodeploy.jar:?]
    at com.apusic.aas.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:379) [aas-deployment-autodeploy.jar:?]
    at com.apusic.aas.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:209) [aas-deployment-autodeploy.jar:?]
    at java.util.TimerThread.mainLoop(Timer.java:555) [?:1.8.0_172]
    at java.util.TimerThread.run(Timer.java:505) [?:1.8.0_172]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter]: Constructor threw exception; nested exception is java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    com/fasterxml/jackson/databind/cfg/MapperBuilder.streamFactory()Lcom/fasterxml/jackson/core/TokenStreamFactory; @7: areturn
  Reason:
    Type 'com/fasterxml/jackson/core/JsonFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/TokenStreamFactory' (from method signature)
  Current Frame:
    bci: @7
    flags: { }
    locals: { 'com/fasterxml/jackson/databind/cfg/MapperBuilder' }
    stack: { 'com/fasterxml/jackson/core/JsonFactory' }
  Bytecode:
    0x0000000: 2ab4 0002 b600 08b0                    

    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:217) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1315) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    ... 56 more
Caused by: java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    com/fasterxml/jackson/databind/cfg/MapperBuilder.streamFactory()Lcom/fasterxml/jackson/core/TokenStreamFactory; @7: areturn
  Reason:
    Type 'com/fasterxml/jackson/core/JsonFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/TokenStreamFactory' (from method signature)
  Current Frame:
    bci: @7
    flags: { }
    locals: { 'com/fasterxml/jackson/databind/cfg/MapperBuilder' }
    stack: { 'com/fasterxml/jackson/core/JsonFactory' }
  Bytecode:
    0x0000000: 2ab4 0002 b600 08b0                    

    at com.fasterxml.jackson.databind.json.JsonMapper.builder(JsonMapper.java:114) ~[jackson-databind-2.11.4.jar:2.11.4]
    at org.springframework.integration.support.json.Jackson2JsonObjectMapper.<init>(Jackson2JsonObjectMapper.java:74) ~[spring-integration-core-5.3.8.RELEASE.jar:5.3.8.RELEASE]
    at org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter.initDefaults(ConfigurableCompositeMessageConverter.java:114) ~[spring-integration-core-5.3.8.RELEASE.jar:5.3.8.RELEASE]
    at org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter.<init>(ConfigurableCompositeMessageConverter.java:68) ~[spring-integration-core-5.3.8.RELEASE.jar:5.3.8.RELEASE]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_172]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_172]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_172]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_172]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:204) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1315) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    ... 56 more

版本号:202106101338

解决时间:2021-11-10

解决方案:在应用的WEB-INF内加入附件中的apusic.xml,并重新发布应用。

apusic.xml内容如下:

1、类型一:(不能解决应用内的jar冲突)

<?xml version="1.0" encoding="UTF-8"?>
<aas-web-app>
   <class-loader delegate="false"/>
</aas-web-app>

2、类型二:

<?xml version="1.0" encoding="UTF-8"?>
<aas-web-app>
   <class-loader delegate="true"  prefer-app-pkg="com.fasterxml.jackson;redis.clients"/>
</aas-web-app>

<?xml version="1.0" encoding="UTF-8"?>
<aas-web-app>
   <class-loader delegate="true"  prefer-app-pkg="com.fasterxml.jackson"/>

   <class-loader delegate="true"  prefer-app-pkg="redis.clients"/>
</aas-web-app>

界面现象:

日志截图:

解决操作: