0

I was trying to set-up this Spring-Session example using Spring Boot + Maven (the source in the GIT link is using Gradle). There were no compilation error, the deploy-able WAR file also got generated using the repackage goal.

When trying to deploy the WAR file in my WildFly server, i get the following error related to Redis. I do not have Redis server running in my machine (since i assume that an embedded Redis instance will be created as part of the application, even in an deployed WAR file)

File: EmbeddedRedisConfiguration.java

Caused by:

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)

Environment: WildFly8.2 running in Domain Mode (3 nodes running in Full-HA profile) Application: 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.

Complete Error Stack:

[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] 
yathirigan
  • 5,619
  • 22
  • 66
  • 104

2 Answers2

1

Based on your stacktrace it looks like the embedded configuration is having trouble working on WildFly. I created an issue to address it

In the meantime you can run on WildFly by:

  • Removing EmbeddedRedisConfiguration
  • Ensure to start an external Redis instance up. You can find directions for installing Redis in the Redis documentation

NOTE: Embedded Redis is not meant for production and is just intended to allow developers to try things easily. Therefore this is viewed as a rather minor issue.

Rob Winch
  • 21,440
  • 2
  • 59
  • 76
  • thank you, what maven/spring configuration would i require for my application code to connect & persist it's Spring Session to this external Redis instance ? any port numbers..etc ? I got this doubt after seeing a reservePort() definition in the Gradle config that comes along with the Spring Session example. – yathirigan Feb 17 '15 at 19:45
  • The reservePort is to find an available port so I can run on a CI server (i.e. I don't know what ports are free on the CI server, so it should pick a random available port). – Rob Winch Feb 17 '15 at 19:49
  • so, as long as an external Redis instance is up and running in my same machine as WildFly , will the code work ? am trying to know if i have to point the spring code or WildFly to this Redis instance for this example to work – yathirigan Feb 17 '15 at 19:54
  • 1
    You can point to any port and any host you like. The sample you pointed at is currently using localhost and the default Redis port (6379). You can customize it by specifying the connection information on JedisConnectionFactory in HttpSessionConfig See https://github.com/spring-projects/spring-session/blob/1.0.0.RELEASE/samples/boot/src/main/java/sample/config/HttpSessionConfig.java#L14 – Rob Winch Feb 17 '15 at 20:01
  • @RobWinch I don't think the issue is related specifically WildFly. Since I encountered exactly the same with embedded tomcat trying to run on localhost. We desperately need maven !correct! sample project configuration as we wasted time to run gradle examples. Great idea but too many issues with this project. – Aubergine Mar 21 '15 at 20:30
  • @Aubergine Please provide any details you can on https://github.com/spring-projects/spring-session/issues/150 so that we can try to figure out what is wrong. – Rob Winch Mar 23 '15 at 14:58
1

This is acutally because the embedded-redis-0.5.jarn pulled in from maven is different from gradle, if you can manage to put the embedded-redis-0.5.jar from gradle into the jar built from maven, it will work.

Ben
  • 11
  • 2