Help creating a document with API

Hi. I’m trying to make a custom API for creating documents. I’m following the example in the document, but getting ClassCastException with the wpm.createObject() method.

                String beanPath = wpm.createAndReturn(
HippoDocument hippoDocument = (HippoDocument) wpm.getObject(beanPath); //works
EventDocument eventDocumentBean = (EventDocument) wpm.getObject(beanPath); //doesn't work
java.lang.ClassCastException: class org.hippoecm.hst.content.beans.standard.HippoDocument$EventDocument$4vkQoxwy cannot be cast to class (org.hippoecm.hst.content.beans.standard.HippoDocument$EventDocument$4vkQoxwy and are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @3bb44eac)

Any ideas?

Thank you.