# Class cast exception in API

**URL:** https://community.bloomreach.com/t/class-cast-exception-in-api/3664
**Category:** Content SaaS
**Created:** [February 16, 2023, 6:56pm UTC](https://community.bloomreach.com/t/class-cast-exception-in-api/3664 "2023-02-16T18:56:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Joshua\_Glickman](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/joshua_glickman/32/1464_2.png) [@Joshua\_Glickman](https://community.bloomreach.com/u/Joshua_Glickman)
#### Post date: [February 16, 2023, 6:56pm UTC](https://community.bloomreach.com/t/class-cast-exception-in-api/3664/1 "2023-02-16T18:56:36Z")

</div>

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

```auto
HippoDocument hippoDocument = (HippoDocument) wpm.getObject(beanPath); //works
EventDocument eventDocumentBean = (EventDocument) wpm.getObject(beanPath); //doesn't work

```

```auto
java.lang.ClassCastException: class org.hippoecm.hst.content.beans.standard.HippoDocument$EventDocument$4vkQoxwy cannot be cast to class org.sae.cm.modules.document.EventDocument (org.hippoecm.hst.content.beans.standard.HippoDocument$EventDocument$4vkQoxwy and org.sae.cm.modules.document.EventDocument are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @3bb44eac)

```

Any ideas?

Thank you.

---

<div class="post-metadata">

### Author: ![jasper.floor](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/jasper.floor/32/28_2.png) [@jasper.floor](https://community.bloomreach.com/u/jasper.floor)
#### Post date: [February 21, 2023, 9:30am UTC](https://community.bloomreach.com/t/class-cast-exception-in-api/3664/2 "2023-02-21T09:30:32Z")

</div>

I would guess you have different EventDocument classes in your project. If not, could you share the EventDocument class?

---

<div class="post-metadata">

### Author: ![Lef\_Karamoulas](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/lef_karamoulas/32/82_2.png) [@Lef\_Karamoulas](https://community.bloomreach.com/u/Lef_Karamoulas)
#### Post date: [February 21, 2023, 9:43am UTC](https://community.bloomreach.com/t/class-cast-exception-in-api/3664/3 "2023-02-21T09:43:49Z")

</div>

@Joshua_Glickman is this the same with [Help creating document in API](https://community.bloomreach.com/t/help-creating-document-in-api/3669) ?  
If so could you please keep one active? Thanks in advance!

Ps. It would be better if you delete this one as this is the Content SaaS section and your question relates to PaaS
