Search code examples
javanode.jsmavenappium

Launching Appium Service programmatically failing


I have an Appium test project that was created about nine months ago, and was working fine. I'd since that time attempted to work on that project again, and the project works, but only if I start Appium manually (with the desktop app). The project checks for the server to see if it's already running, and if not, launches it using the service logic below:

public class AppiumServer {

    AppiumDriverLocalService service = null;

    public void InitAppiumServer() {

        System.out.println("Creating Appium Service . . .");
        service = AppiumDriverLocalService.buildDefaultService();
        System.out.println("Appium Service created.  URL: '" + service.getUrl().toString() + "'");

    }

    public void startServer() {

        System.out.println("Starting Appium Service . . .");
        service.start();
        System.out.println("Appium Service started.");

    }

The resulting output, when Appium is not started manually, is below:

Creating Appium Service . . . Appium Service created. URL: 'http://0.0.0.0:4723/wd/hub' Checking for Appium Service on port 4723 . . . No prior Appium Service detected. Starting Appium Service . . . io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: [C:\Users\m1033792\AppData\Roaming\npm\node_modules\appium\build\lib\main.js, --port, 4723, --address, 0.0.0.0]

If I open a command prompt and run that command line manually, it also works, just not using the standard method that I've been using and it would see, from research, most others are using. I also seem to not be the only person with this particular problem as I'm seeing it posted many places on the web, but with no responses.

My nodejs is version 5.6.0 Appium (via nvm install) is 1.8 Java is 1.8.0_144 Maven is 3.5.4


Solution

  • After extensive research and trial-and-error, I looked deeper into the stack trace and noticed that it referred to:

    com.google.common.util.concurrent.SimpleTimeLimiter.create(Ljava/util/concurrent/ExecutorService;)Lcom/google/common/util/concurrent/SimpleTimeLimiter

    As "not existing" Further research showed others with the same problem with other services, not necessarily the Appium Server, and it was tied to my guava being at version 21.0 instead of 23.0.

    Once I updated that setting in my pom.xml, the project ran error-free once again.

    This is on me for not posting the -entire- stack trace in my question. Lesson learned.