Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index - out of bounds for length 0

“Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: Index - out of bounds for length 0” is thrown when I try to execute my bot.

My main method:

public static void main(String[] args) {
BotExecutor.run(new FirstBot(), args);
}

1 Like

Hi Leonardo,

This problem usually happens when you try to run your bot locally from IDE or command line, but it’s expecting to be run via BotRunner app.

BotExecutor.run basically gets a list of parameters passed by args[] and setup the execution environment (represented by the BotExecution class). BotRunner app is responsible to get the execution parameters from BotMaestro (Orchestrator) and pass it to your bot.

If you want to run your bot directly from your IDE or command line, you need to change your main method to not use BotMaestro integration.

public static void main(String[] args) {
	new FirstBot().action(null);
}

But it’s important to reverse this change before deploying your bot on BotMaestro.