# JSF & JTA Transaction

**URL:** <https://discourse.hibernate.org/t/jsf-jta-transaction/2267>\
**Category:** Hibernate ORM\
**Created:** [February 12, 2019, 3:43pm UTC](https://discourse.hibernate.org/t/jsf-jta-transaction/2267 "2019-02-12T15:43:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Broots](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@Broots](https://discourse.hibernate.org/u/Broots)\
**Post date:** [February 12, 2019, 3:43pm UTC](https://discourse.hibernate.org/t/jsf-jta-transaction/2267/1 "2019-02-12T15:43:13Z")

</div>

Hi,

Is it possible when we call a jsf action on an inner bean to have a JTA transaction active ? ELResolver ? Interceptor ?  
Here Load & Flush : An exception is raised . No transaction is in progress.  
When EL resolves #{entity2Bean.innerBean} =\> a JTA is opened and closed to get innerBean.  
But the JTA Transaction is not still active when the method flush is called.

Any Ideas ?

Thanks

Sebastien

```auto
<h:body>
	<h:form>
	        <h:commandButton value="Load" action="#{entity2Bean.innerBean.load}"/>
	        <h:commandButton value="Flush" action="#{entity2Bean.innerBean.flush}"/>
	</h:form>   
</h:body>

@Named
@Stateful
@SessionScoped
public class Entity2Bean implements Entity2BeanInterface {

  @PersistenceContext(type = PersistenceContextType.EXTENDED)
  private EntityManager entityManager;

  private InnerBean innerBean;

  public EntityManager getEntityManager() {
    return entityManager;
  }

  public InnerBean getInnerBean() {
    if (innerBean == null) {
      innerBean = new InnerBean();
    }
    innerBean.setEntity2Bean(this);
    return innerBean;
  }

  public void setInnerBean(InnerBean innerBean) {
    this.innerBean = innerBean;
  }

  @Remove
  public void checkout() {
  }

public interface Entity2BeanInterface {
  public InnerBean getInnerBean();
}

public class InnerBean implements Serializable {

  private Entity entity;
  private Entity2Bean entity2Bean;
  
  public Entity getEntity() {
    return entity;
  }

  public void setEntity(Entity entity) {
    this.entity = entity;
  }

  public Entity2Bean getEntity2Bean() {
    return entity2Bean;
  }

  public void setEntity2Bean(Entity2Bean entity2Bean) {
    this.entity2Bean = entity2Bean;
  }

  public void load() {
    entity = (Entity) getEntity2Bean().getEntityManager().find(Entity.class, 1L);

  }

  public void flush() {
    getEntity().setName("XXXX");
    getEntity2Bean().getEntityManager().flush();
  }
}

```

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [February 12, 2019, 5:51pm UTC](https://discourse.hibernate.org/t/jsf-jta-transaction/2267/2 "2019-02-12T17:51:24Z")

</div>

Did you add the `@Transactional` annotation to your service methods?

---

<div class="post-metadata">

**Author:** ![Broots](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@Broots](https://discourse.hibernate.org/u/Broots)\
**Post date:** [February 13, 2019, 1:04pm UTC](https://discourse.hibernate.org/t/jsf-jta-transaction/2267/3 "2019-02-13T13:04:15Z")

</div>

> [@vlad](#):
>
> @Transactional

I’ve annotated my methods load & flush & getInnerBean with @Transactional.  
Still the same error.

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [February 13, 2019, 1:54pm UTC](https://discourse.hibernate.org/t/jsf-jta-transaction/2267/4 "2019-02-13T13:54:24Z")

</div>

Well question is more about bootstrapping Hibernate with JSF so it’s much better to ask it on a JSF forum.

I have never used JSF, so I can’t help you.

---

<div class="post-metadata">

**Author:** ![Broots](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@Broots](https://discourse.hibernate.org/u/Broots)\
**Post date:** [February 13, 2019, 2:03pm UTC](https://discourse.hibernate.org/t/jsf-jta-transaction/2267/5 "2019-02-13T14:03:42Z")

</div>

Ok. I will try on another forum. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [February 13, 2019, 4:24pm UTC](https://discourse.hibernate.org/t/jsf-jta-transaction/2267/6 "2019-02-13T16:24:32Z")

</div>

You are very welcome. Try to address the question on the JBoss forum as there might be people that have previously used JSF.
