Fix initialization for the ApiListener class

fixes #7780