gpt4 book ai didi

java - 尝试使用 Spring Boot 2 启动 Gemfire 脉冲时出现 Jackson Cast 异常

转载 作者:行者123 更新时间:2023-12-02 01:05:07 27 4
gpt4 key购买 nike

我已经使用 Spring Pivotal Gemfire 创建了一个定位器应用程序。根据文档,我在启动应用程序时设置了 GEODE_HOME。当我尝试从 gfsh 命令提示符进行连接时。它尝试从 GEODE_HOME 部署脉冲并抛出以下错误以进行 jackson 类型转换。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Constructor threw exception; nested exception is java.lang.ClassCastException: class com.fasterxml.jackson.datatype.jdk8.Jdk8Module cannot be cast to class com.fasterxml.jackson.databind.Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module is in unnamed module of loader 'app'; com.fasterxml.jackson.databind.Module is in unnamed module of loader org.eclipse.jetty.webapp.WebAppClassLoader @18a3c727)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1104) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[na:na]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:930) ~[jetty-server-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:553) ~[jetty-servlet-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:889) ~[jetty-server-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:356) ~[jetty-servlet-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1445) ~[jetty-webapp-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1409) ~[jetty-webapp-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:822) ~[jetty-server-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:275) ~[jetty-servlet-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524) ~[jetty-webapp-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72) ~[jetty-util-9.4.25.v20191220.jar:9.4.25.v20191220]
at org.apache.geode.internal.cache.HttpService.addWebApplication(HttpService.java:169) ~[geode-core-9.8.4.jar:na]
at org.apache.geode.management.internal.ManagementAgent.loadWebApplications(ManagementAgent.java:232) ~[geode-core-9.8.4.jar:na]
at org.apache.geode.management.internal.ManagementAgent.startAgent(ManagementAgent.java:127) ~[geode-core-9.8.4.jar:na]
at org.apache.geode.management.internal.SystemManagementService.startManager(SystemManagementService.java:432) ~[geode-core-9.8.4.jar:na]
at org.apache.geode.management.internal.JmxManagerLocator.findJmxManager(JmxManagerLocator.java:102) ~[geode-core-9.8.4.jar:na]
at org.apache.geode.management.internal.JmxManagerLocator.processRequest(JmxManagerLocator.java:52) ~[geode-core-9.8.4.jar:na]
at org.apache.geode.distributed.internal.InternalLocator$PrimaryHandler.processRequest(InternalLocator.java:1309) ~[geode-core-9.8.4.jar:na]
at org.apache.geode.distributed.internal.tcpserver.TcpServer.processOneConnection(TcpServer.java:475) ~[geode-core-9.8.4.jar:na]
at org.apache.geode.distributed.internal.tcpserver.TcpServer.lambda$processRequest$0(TcpServer.java:369) ~[geode-core-9.8.4.jar:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Constructor threw exception; nested exception is java.lang.ClassCastException: class com.fasterxml.jackson.datatype.jdk8.Jdk8Module cannot be cast to class com.fasterxml.jackson.databind.Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module is in unnamed module of loader 'app'; com.fasterxml.jackson.databind.Module is in unnamed module of loader org.eclipse.jetty.webapp.WebAppClassLoader @18a3c727)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1152) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
... 35 common frames omitted
Caused by: java.lang.ClassCastException: class com.fasterxml.jackson.datatype.jdk8.Jdk8Module cannot be cast to class com.fasterxml.jackson.databind.Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module is in unnamed module of loader 'app'; com.fasterxml.jackson.databind.Module is in unnamed module of loader org.eclipse.jetty.webapp.WebAppClassLoader @18a3c727)
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.registerWellKnownModulesIfAvailable(Jackson2ObjectMapperBuilder.java:740) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.configure(Jackson2ObjectMapperBuilder.java:607) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:590) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.<init>(MappingJackson2HttpMessageConverter.java:57) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:66) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.<init>(RequestMappingHandlerAdapter.java:204) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[na:na]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
... 37 common frames omitted

最佳答案

此问题应在 Geode 1.11.0 中修复并由此 Jira 覆盖:https://issues.apache.org/jira/browse/GEODE-7334 .

以下是问题的一些背景信息和潜在的解决方法:(对“joda”的引用可以替换为“jdk8”)

当 web 应用程序启动时,它会加载 com.fasterxml.jackson.databind.Module (这是一个抽象类)使用 web 应用程序的类加载器。在某些时候 Spring 会尝试加载各种 ObjectMappers Jackson2ObjectMapperBuilder.java#L772-L822 。在本例中,它在系统类路径上找到joda模块。为了解决com.fasterxml.jackson.datatype.joda.JodaModule类(由系统类加载器),它还需要加载 com.fasterxml.jackson.databind.Module然后由系统类加载器加载。然而,这意味着JodaModulec.f.j.d.Module 不兼容由 webapp 加载的类;导致异常。

只要所有必需的 jackson jar 都位于系统类路径上,解决方法就是从 webapp jar 中删除所有 jackson jar。例如:zip -d .../tools/Pulse/geode-pulse-1.10.0.war WEB-INF/lib/jackson\*

关于java - 尝试使用 Spring Boot 2 启动 Gemfire 脉冲时出现 Jackson Cast 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60154427/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com