This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
29 / 36
Aug 2017
5 months later

Hi

I am getting below error while starting appium server using above method.
It would be great, if you can help to solve this issue.

I am using 1.4.16 appium version on Mac

io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: /usr/local/bin/node Arguments: [/usr/local/lib/node_modules/appium/bin/appium.js, --port, 32394, --address, 127.0.0.1, --udid, 192.168.59.101:5555, --log-level, warn:error:info, --chromedriver-port, 59215, --bootstrap-port, 59214, --no-reset, --nodeconfig, /Users/mayur_d/Test_Branch_3.12/target/test-classes/GridConfig.json, --session-override]

at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:140)
at com.test.gridsetup.GridConfig$1.run(GridConfig.java:202)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/exec/DaemonExecutor
at org.openqa.selenium.os.UnixProcess.(UnixProcess.java:52)
at org.openqa.selenium.os.CommandLine.(CommandLine.java:38)
at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:125)
... 4 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.exec.DaemonExecutor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more

Code i have written is
private void startAppiumServer(final Client client, final String nodeConfigFilePath) throws InterruptedException {
Logger.info("Starting appium server");

	executorService = Executors.newSingleThreadExecutor();
	executorService.execute(new Runnable() {
		public void run() {
			try {
				AppiumDriverLocalService driverLocalService = AppiumDriverLocalService
						.buildService(new AppiumServiceBuilder()
								.withAppiumJS(new File("/usr/local/lib/node_modules/appium/bin/appium.js"))
								.usingDriverExecutable(new File("/usr/local/bin/node")).withIPAddress("127.0.0.1")
								.usingAnyFreePort().withArgument(GeneralServerFlag.UIID, client.getSerialNo())
								.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,
										"" + client.getBootstrapPort())
								.withArgument(GeneralServerFlag.CHROME_DRIVER_PORT,
										"" + client.getChromeDriverport())
								.withArgument(GeneralServerFlag.NO_RESET)
								.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
								.withArgument(GeneralServerFlag.LOG_LEVEL, "warn:error:info")
								.withArgument(GeneralServerFlag.CONFIGURATION_FILE, nodeConfigFilePath));
				Logger.info("Server url: " + driverLocalService.getUrl());
				driverLocalService.start();
			} catch (Exception e) {
				Logger.error("Failed to start appium server. ");
				e.printStackTrace();
			}
		}
	});
}
2 months later

Hey. I got below error while following the above step:

/usr/local/lib/node_modules/appium/bin/appium.js:1
(function (exports, require, module, __filename, __dirname) { import _ from 'lodash’;
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:449:3

Hi, I got the error while following the same approach.

/usr/local/lib/node_modules/appium/bin/appium.js:1
(function (exports, require, module, __filename, __dirname) { import _ from 'lodash’;
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:449:3

1 month later

In my case it works only if i mention

...........    
.withAppiumJS(
		new File(
	"/usr/local/lib/node_modules/appium/bin/main.js"))
................
3 months later

Got the same issue after I upgrade the node and Appium to 1.6, any solution of it?

Try to use main.js instead of appium.js like below

service = new AppiumServiceBuilder()
.usingDriverExecutable(new File("/Users/ssimakurthy/local/bin/node"))
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"));

Please clarify if you're trying to register android node with Selenium HUB with this code ?

are you able to get this issue resolved ?

Thanks in advance.

Just to update on this thread for benefit of others, with below code I could get appiun node registered with Selenium HUB

String nodeConfigFilePath = "/Users/Mobile-Automation/Android-Automation/serenityAppiumFlipkart/EMULATOR_Nexus_4_1.json";

    	 AppiumDriverLocalService driverLocalService = AppiumDriverLocalService
    			.buildService(new AppiumServiceBuilder()
    					.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
    					.usingDriverExecutable(new File("/usr/local/bin/node"))
    					//.withIPAddress("127.0.0.1")
    					.usingPort(4445)
    					//.withArgument(GeneralServerFlag.UIID, "123456")    					
    					//.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,
    					//		"" + 2252)
    					//.withArgument(GeneralServerFlag.CHROME_DRIVER_PORT,
    					//		"" + client.getChromeDriverport())
    					//.withArgument(GeneralServerFlag.NO_RESET)
    					.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
    					.withArgument(GeneralServerFlag.LOG_LEVEL, "debug")
    					.withArgument(GeneralServerFlag.CONFIGURATION_FILE, nodeConfigFilePath));
    	//Logger.info("Server url: " + driverLocalService.getUrl());
    	driverLocalService.start();

Before you run this program, make sure to try it out from command line with below command

appium --nodeconfig EMULATOR_Nexus_4_1.json --port 4445

In case you do something wrong as appium --nodeconfig EMULATOR_Nexus_4_1.json --bp 2252, you will get nice output about flags usage

Couple of open queries still as below

  1. it didn't work with usingAnyFreePort(), I had to explicitly mention port number.

  2. I could register android emulator node, even when it was not in open state, not sure if this is valid ?

Regards,
Vikram

Kindly ignore above answer

Below is the working solution, will share completed project in few weeks

{"capabilities":[{"browserName":"Android","version":"4.4.2","maxInstances":1,"platform":"ANDROID","deviceName":"emulator-5556"}],"configuration":{"nodeTimeout":120,"port":4723,"hubPort":4444,"proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy","hubHost":"127.0.0.1", "nodePolling":2000, "registerCycle":10000,"register":true,"cleanUpCycle":2000,"timeout":30000,"maxSession":1}}

    	nodeConfigFilePath = "/Users/vikram-anna/.../EMULATOR_Nexus_4_2.json";
    	driverLocalService = AppiumDriverLocalService
		.buildService(new AppiumServiceBuilder()
				.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
				.usingDriverExecutable(new File("/usr/local/bin/node"))					
				.usingPort(4823)
				.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,"4824")
				.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
				.withArgument(GeneralServerFlag.LOG_LEVEL, "debug")
				.withArgument(GeneralServerFlag.CONFIGURATION_FILE, nodeConfigFilePath));

         driverLocalService.start();
7 months later

Hi @suroit
How did you resolved it. Even me too facing same issue. I am using appium-desktop 1.1.1 and I installed Node.js manually. Below is my code and error. Can you please help?
appiumService = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File(“C:/Program Files/nodejs/node”))
.withAppiumJS(new File(“C:/Users/ss.k/AppData/Local/Programs/appium-desktop/resources/app/main.js”))
.withIPAddress(“127.0.0.1”)
.usingPort(4723));
appiumService.start();

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\ss.k\AppData\Local\Programs\appium-desktop\resources\app\main.js, --port, 4723, --address, 127.0.0.1]
Process output: Error: Cannot find module ‘electron’

I suggest you try the latest version of appium instead of appium-desktop.

19 days later

Hi guys,
I meet one problem when I try using AppiumDriverLocalSerivce .start() to launch app server, code like below.
public class StartAppium {

private IOSDriver<MobileElement> iosDriver;
private AppiumDriverLocalService service;

@BeforeClass
public void setUp() throws Exception {

	service = AppiumDriverLocalService
			.buildService(new AppiumServiceBuilder().usingDriverExecutable(new File("/usr/local/bin/node"))
					.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
					.withIPAddress("127.0.0.1").usingPort(4723));
	service.start();
}

@Test
public void getAppiumStatus() {

}

@AfterClass
public void tearDown() {
	// iosDriver.quit();
	// service.stop();
}

}

however, I got same errors like below, Appium I was using latest one v1.6.5, but strangely it works fine when I use terminal command “node /usr/local/lib/node_modules/appium/build/lib/main.js”

Exception in thread “main” io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: /usr/local/Cellar/node/8.1.4/bin/node Arguments: [/usr/local/lib/node_modules/appium/build/lib/main.js, --port, 57565, --address, 127.0.0.1, --log-level, info, --bootstrap-port, 57567, --suppress-adb-kill-server, --selendroid-port, 57568]

at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:149)
at appium.Manager.DeviceConfigurationImpl.main(DeviceConfigurationImpl.java:45)

Caused by: java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker
at org.openqa.selenium.net.UrlChecker.(UrlChecker.java:67)
at io.appium.java_client.service.local.AppiumDriverLocalService.ping(AppiumDriverLocalService.java:113)
at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:136)
… 1 more

1 month later

@Sun_Yujiang
I am having the same problem of

Caused by: java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker

when using AppiumDriverLocalSerivce .start() to start appium server.

Did you get a solution?

public static void startServer() throws Exception {

	try {

		logIOSDriverAPI.info("Starting Appium on terminal from AppiumDriverLocalService");
		Map<String, String> env = new HashMap<String, String>(System.getenv());
		env.put("PATH", "/usr/local/bin:" + env.get("PATH"));
		AppiumServiceBuilder builder = new AppiumServiceBuilder()
				.withIPAddress(appiumInit.SERVERIP)
				.usingPort(appiumInit.APPIUMPORT)
				.withEnvironment(env)
				.withArgument(GeneralServerFlag.LOG_NO_COLORS)
				.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
				.withArgument(GeneralServerFlag.LOG_LEVEL, "warn:error:info")
				.usingDriverExecutable(new File("/usr/local/bin/node"))
				.withAppiumJS(new File("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js"));


		driverLocalService = AppiumDriverLocalService.buildService(builder);
		driverLocalService.start();
	

	} catch (Exception e) {
		throw new Exception("Exception occoured while starting the appium server");

	}
	try {

		Thread.sleep(10000);
	} catch (Exception e) {
		e.printStackTrace();
	}

}
11 days later

Hi,

I am facing same issue. i used above code, but no use.

Environment :
Apium version : 17.1
Node : 8.7.0
xcode :9.0
java clinet : 5.0.4

Using following code to start appium :

Map<String, String> env = new HashMap<>(System.getenv());
env.put(“PATH”, “/usr/local/bin:” + env.get(“PATH”));

AppiumServiceBuilder builder = new AppiumServiceBuilder()
.withArgument(IOSServerFlag.WEBKIT_DEBUG_PROXY_PORT, webkit)
.withIPAddress(“127.0.0.1”)
.usingPort(port).withEnvironment(env)
.usingDriverExecutable(new File("/usr/local/bin/node"))
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"));

AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder);
service.start();**

Can anyone suggest me how to solve this issue.

public static void startServer() throws Exception {

	try {

		logIOSDriverAPI.info("Starting Appium on terminal from AppiumDriverLocalService");
		Map<String, String> env = new HashMap<String, String>(System.getenv());
		env.put("PATH", "/usr/local/bin:" + env.get("PATH"));
		AppiumServiceBuilder builder = new AppiumServiceBuilder()
				.withIPAddress(appiumInit.SERVERIP)
				.usingPort(appiumInit.APPIUMPORT)
				.withEnvironment(env)
				.withArgument(GeneralServerFlag.LOG_NO_COLORS)
				.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
				.withArgument(GeneralServerFlag.LOG_LEVEL, "warn:error:info")
				.usingDriverExecutable(new File("/usr/local/bin/node"))
				.withAppiumJS(new File("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js"));


		driverLocalService = AppiumDriverLocalService.buildService(builder);
		driverLocalService.start();
	

	} catch (Exception e) {
		throw new Exception("Exception occoured while starting the appium server");

	}
	try {

		Thread.sleep(10000);
	} catch (Exception e) {
		e.printStackTrace();
	}

}