Yes, you definitely need to use an entity reference resolver here:

    DocumentReference classRef = currentDocumentReferenceResolver.resolve(className);

Using ``xClassEntityReferenceResolver`` would have been better, but some of the methods you use below are expecting a ``DocumentReference``.