GROOVY-5802: Exception thrown in groovyConsole

Combines two "bugs". Either would solve the problem given but it seemed to make sense to cover both cases.