JSF & JTA Transaction

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

<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();
  }
}

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

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

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.

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

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