kstyrc / embedded-redis

Redis embedded server for Java integration testing
863 stars 373 forks source link

start redis server on own executable fail #86

Open zhouhoo opened 7 years ago

zhouhoo commented 7 years ago

When use fellow way to create a redis server based on own executable, it fail . String redisPath ="/usr/local/bin/redis-server"; File file = new File(redisPath); RedisServer redisServer = new RedisServer(file, 6379); with error as fellow: Exception in thread "main" redis.embedded.exceptions.EmbeddedRedisException: Failed to start Redis instance at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:42) at redis.embedded.RedisServer.start(RedisServer.java:9) at com.blue.util.VoiceRecognation.start_s(VoiceRecognation.java:44) at com.blue.util.VoiceRecognation.main(VoiceRecognation.java:167) Caused by: java.io.IOException: Cannot run program "/usr/local/bin/redis-server " (in directory "/usr/local/bin"): error=2,no such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047) at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:37) ... 3 more Caused by: java.io.IOException: error=2, no such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:187) at java.lang.ProcessImpl.start(ProcessImpl.java:130) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028) ... 4 more but the file is truly there and with 755 .
my own redis executable version is 3.2 , ubuntu14.04. so this is a bug?

tklovett commented 7 years ago

It looks like there is an extra trailing space in the name of the executable that ProcessBuilder is attempting to start: "/usr/local/bin/redis-server ". Is there a typo in your assignment to String redisPath? Or maybe something is modifying it before it's passed to new ProcessBuilder(args);?

tklovett commented 7 years ago

For anyone else with my issue: I got this same error attempting to run my application within Alpine Linux -- the embedded redis-server-2.8.19 OsArchitecture.UNIX_x86_64 executable is successfully extracted from the Jar to /tmp/*, but Alpine is unable to execute it.

izebit commented 7 years ago

@tklovett I faced with this problem too and I suggest that I have found a reason of the error. The problem in Alpine distribution, the os does't work with the format of program. It needs recompilation of redis, which contains in jar. So, if you want read about it more , you can go to https://github.com/awslabs/amazon-kinesis-producer/issues/86

mengjiann commented 6 years ago

As similar to the situation above, I encountered the problem with running the embedded redis server in a Docker container. The image was originated from java:8-jre-alpine. It works after changing the base image to: openjdk:8-jre. But, the built docker image becomes larger though :)

IEnoobong commented 2 years ago

Any way to fix this other than changing the base image please?

ycyin commented 8 months ago

As similar to the situation above, I encountered the problem with running the embedded redis server in a Docker container. The image was originated from java:8-jre-alpine. It works after changing the base image to: openjdk:8-jre. But, the built docker image becomes larger though :)

yeah! I change maven:3.9.6-eclipse-temurin-11-alpine to maven:3.9.6-eclipse-temurin-11 and it works.