11 Replies Latest reply on Nov 25, 2005 5:02 AM by Frank Stolle

    JBoss bug ou EJB bug???

    Leandro Sinhorini Alves Newbie

      I've be seding this question for forums and JBoss/EJB3 jira and I have no answer until now. I realy need to know if this problem is a bug ou a normal behavior of EJB.

      I'm using JBoss 4.0.3SP1 + EJB3 RC3 + MyFaces.

      In a JSF managed bean, my application begin a JTA transaction and invoke a stateless session bean that return a entity bean. The entity bean has a lazy collection that throws org.hibernate.LazyInitializationException when I try to get it at managed bean method.

      Follow the managed bean method:

      public String consultar() throws Exception {
       ServiceLocator locator = ServiceLocator.getInstance();
       UserTransaction tx = (UserTransaction) locator.lookup( "java:comp/UserTransaction" );
       try {
       AplicacaoFacade facade = locator.lookupEJB( AplicacaoFacade.class );
       // Get informations for page
       vo = (UsuarioVO) paginaRegistros.getRowData();
       Usuario usuario = facade.getUsuarioPorId( vo.getId() );
       // Build organizations collection
       List<Long> organizacoesId = new ArrayList<Long>();
       // THROWS LAZY EXCEPTION !!!!!!
       for ( Organizacao organizacao : usuario.getOrganizacoes() ) {
       organizacoesId.add( organizacao.getId() );
       catch ( Exception e ) {
       return Constantes.OUTCOME_SUCESSO;

      The session façade uses dependency injection to get entity manager:

      public class AplicacaoFacadeBean implements AplicacaoFacade {
       @PersistenceContext EntityManager entityManager;
       public Usuario getUsuarioPorId( Long usuarioId ) {
       return entityManager.find( Usuario.class, usuarioId );

      Shouldn't entity manager be open until JTA commit ou rollback?