'Can't use Selenium on a Java server

I tried making a discord patchbot in java (Data is on a dynamic website). While the application works in eclipse and as a .jar on my desktop, I can't get it to work properly on the server. The server is a java-server from sparkedhost.

On every start the following error occurs:

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.IllegalStateException: It must be an executable file: /home/container/botFiles/chromedriver.exe
        at org.openqa.selenium.internal.Require.stateCondition(Require.java:169)
        at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:148)
        at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:142)
        at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:38)
        at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:231)
        at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:437)
        at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:127)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:48)
        at selenium.SeleniumApplicaton.run(SeleniumApplicaton.java:40)
        at main.WebScraper.getNews(WebScraper.java:31)
        at main.DiscordBot.<init>(DiscordBot.java:60)
        at main.DiscordBot.main(DiscordBot.java:27)
        ... 5 more


Solution 1:[1]

Regarding the error message in the stack trace:

It must be an executable file: /home/container/botFiles/chromedriver.exe

The executable you are trying to run (chromedriver.exe) looks like a Windows executable file. But the server you are running it on does not - it starts with a root directory of /, suggesting a Linux box.

Based on that, I think you may need to pick the chromedriver which matches your server operating system.


My guess in the question's comments is converted to an answer, since that turned out to be the solution.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 andrewJames