# Get live variant of bean

**URL:** <https://community.bloomreach.com/t/get-live-variant-of-bean/4467>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [August 5, 2024, 9:49am UTC](https://community.bloomreach.com/t/get-live-variant-of-bean/4467 "2024-08-05T09:49:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SBG](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@SBG](https://community.bloomreach.com/u/SBG)\
**Post date:** [August 5, 2024, 9:49am UTC](https://community.bloomreach.com/t/get-live-variant-of-bean/4467/1 "2024-08-05T09:49:26Z")

</div>

The HippoBean class has methods to get beans by relativ path and other means. It automatically handles the hippo:handles. So you can access a bean selected in a component by something like the following code:

```auto
    public static HippoBean findHippoBean(HstRequestContext context, String path) {
        HippoBean contentBaseBean = context.getSiteContentBaseBean();
        return contentBaseBean.getBean(path);
    }

```

My question is: Is there an easy way to always get the live version of documents? At least in our site the provided code seems to always catch the first of the child nodes of the hippo:handle which tends to be the draft variant.

In most of my use cases I’d prefer getting the live variant or null if the document is currently not published

---

<div class="post-metadata">

**Author:** ![machak](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/machak/32/1298_2.png) [@machak](https://community.bloomreach.com/u/machak)\
**Post date:** [August 5, 2024, 9:53am UTC](https://community.bloomreach.com/t/get-live-variant-of-bean/4467/2 "2024-08-05T09:53:56Z")

</div>

> [@SBG](#):
>
> to always catch the first of the child nodes of the hippo:handle which tends to be the draft variant.

this is transparently handled for you and it is based on user session/jcr session…it should only get draft (preview) variant if you are using preview session (if you are logged into CMS for example and accessing document via channel manager)…otherwise, something is wrong with your setup, either on user level (security domains) or you marked your mount as a preview mount

---

<div class="post-metadata">

**Author:** ![machak](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/machak/32/1298_2.png) [@machak](https://community.bloomreach.com/u/machak)\
**Post date:** [August 5, 2024, 9:55am UTC](https://community.bloomreach.com/t/get-live-variant-of-bean/4467/3 "2024-08-05T09:55:13Z")

</div>

reference:

> **[Delivery Tier Users - Bloomreach Experience Manager (PaaS/Self-Hosted) - The...](https://xmdocumentation.bloomreach.com/library/concepts/security/hst-users.html)**
>
> The fast and flexible on-premise or PaaS headless CMS

---

<div class="post-metadata">

**Author:** ![SBG](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@SBG](https://community.bloomreach.com/u/SBG)\
**Post date:** [August 5, 2024, 10:09am UTC](https://community.bloomreach.com/t/get-live-variant-of-bean/4467/4 "2024-08-05T10:09:06Z")

</div>

Alright I’ll have a look at that and circle back. I was asking because we somehow managed to get an unpublished document displayed in our live site. Might have been a cache or setup issue.

---

<div class="post-metadata">

**Author:** ![SBG](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@SBG](https://community.bloomreach.com/u/SBG)\
**Post date:** [August 21, 2024, 11:38am UTC](https://community.bloomreach.com/t/get-live-variant-of-bean/4467/5 "2024-08-21T11:38:42Z")

</div>

Yupp, seems like we had the great idea to grant the xm.repository.admin userrole to the liveuser. After removing it things work as expected

---

<div class="post-metadata">

**Author:** ![Pselvam](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/pselvam/32/1888_2.png) [@Pselvam](https://community.bloomreach.com/u/Pselvam)\
**Post date:** [December 20, 2024, 7:07am UTC](https://community.bloomreach.com/t/get-live-variant-of-bean/4467/6 "2024-12-20T07:07:52Z")

</div>

Hi @SBG

We are happy you are part of Bloomreach Developer’s Community.  
Thank you for reaching out to us.  
We hope we have answered your queries and therefore marking this thread for Closure.  
Looking forward to your continuous contribution towards our vibrant Bloomreach Community.

Thank you
