gpt4 book ai didi

maven - 使用 Maven 和 Spring Boot 的 Spring Session 示例中的 Redis 错误

转载 作者:可可西里 更新时间:2023-11-01 11:13:33 26 4
gpt4 key购买 nike

我正在尝试设置 this Spring-Session example使用 Spring Boot + Maven(GIT 链接中的源代码使用 Gradle)。没有编译错误,可部署的 WAR 文件也使用重新打包目标生成。

尝试在我的 WildFly 服务器中部署 WAR 文件时,出现以下与 Redis 相关的错误。我的机器上没有运行 Redis 服务器(因为我假设嵌入式 Redis 实例将作为应用程序的一部分创建,即使在已部署的 WAR 文件中也是如此)

文件:EmbeddedRedisConfiguration.java

原因:

java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203) [rt.jar:1.8.0_25]
at java.nio.file.Files.copy(Files.java:2984) [rt.jar:1.8.0_25]
at redis.embedded.RedisServer.extractExecutableFromJar(RedisServer.java:85)
at redis.embedded.RedisServer.<init>(RedisServer.java:69)
at redis.embedded.RedisServer.<init>(RedisServer.java:63)
at hello.EmbeddedRedisConfiguration$RedisServerBean.afterPropertiesSet(EmbeddedRedisConfiguration.java:55)

环境:WildFly8.2 在域模式下运行(3 个节点在 Full-HA 配置文件中运行)应用:Spring Boot + Spring Session + Maven

Question: Is this error because an embedded Redis instance cannot be created while the WAR file is deployed to a container ? I haven't tried running this as executable WAR file yet.

完整的错误堆栈:

[Server:server-four] 23:52:46,815 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host."/gs-spring-boot-0.1.0": org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host."/gs-spring-boot-0.1.0": Failed to start service
[Server:server-four] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
[Server:server-four] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]
[Server:server-four] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]
[Server:server-four] at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]
[Server:server-four] Caused by: java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisServer' defined in class path resource [hello/EmbeddedRedisConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NullPointerException
[Server:server-four] at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:222)
[Server:server-four] at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
[Server:server-four] at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
[Server:server-four] at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
[Server:server-four] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
[Server:server-four] ... 3 more
[Server:server-four] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisServer' defined in class path resource [hello/EmbeddedRedisConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NullPointerException
[Server:server-four] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1554)
[Server:server-four] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
[Server:server-four] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
[Server:server-four] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
[Server:server-four] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
[Server:server-four] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
[Server:server-four] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
[Server:server-four] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:116)
[Server:server-four] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:611)
[Server:server-four] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
[Server:server-four] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
[Server:server-four] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
[Server:server-four] at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
[Server:server-four] at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:142)
[Server:server-four] at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:89)
[Server:server-four] at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:51)
[Server:server-four] at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
[Server:server-four] at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:182)
[Server:server-four] ... 7 more
**[Server:server-four] Caused by: java.lang.NullPointerException
[Server:server-four] at java.util.Objects.requireNonNull(Objects.java:203) [rt.jar:1.8.0_25]
[Server:server-four] at java.nio.file.Files.copy(Files.java:2984) [rt.jar:1.8.0_25]
[Server:server-four] at redis.embedded.RedisServer.extractExecutableFromJar(RedisServer.java:85)
[Server:server-four] at redis.embedded.RedisServer.<init>(RedisServer.java:69)
[Server:server-four] at redis.embedded.RedisServer.<init>(RedisServer.java:63)
[Server:server-four] at hello.EmbeddedRedisConfiguration$RedisServerBean.afterPropertiesSet(EmbeddedRedisConfiguration.java:55)**
[Server:server-four] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1613)
[Server:server-four] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1550)
[Server:server-four] ... 24 more
[Server:server-four]

最佳答案

根据您的堆栈跟踪,嵌入式配置似乎无法在 WildFly 上运行。我创建了 an issue解决它

在此期间,您可以通过以下方式在 WildFly 上运行:

  • 删除 EmbeddedRedisConfiguration
  • 确保启动外部 Redis 实例。您可以在 Redis documentation 中找到安装 Redis 的说明。

注意:嵌入式 Redis 不适用于生产环境,只是为了让开发人员能够轻松地进行尝试。因此,这被视为一个相当小的问题。

关于maven - 使用 Maven 和 Spring Boot 的 Spring Session 示例中的 Redis 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28569395/

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