Java 返回的无状态会话Bean方法未完成事务
我使用glassfish 4.1 我的代码是Java 返回的无状态会话Bean方法未完成事务,java,jpa,glassfish-4,Java,Jpa,Glassfish 4,我使用glassfish 4.1 我的代码是 @Stateless @TransactionManagement(TransactionManagementType.BEAN) public class IslemEJB<T, U> { @PersistenceContext(unitName = "etobsSentinelPU") private EntityManager em; @Resource private
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class IslemEJB<T, U> {
@PersistenceContext(unitName = "etobsSentinelPU")
private EntityManager em;
@Resource
private UserTransaction ut;
private T t;
private U u;
public T updateMesajsizWithReturn(T t) {
try {
ut.begin();
t = em.merge(t);
em.flush();
System.out.println(" Log id " + t);
ut.commit();
}
catch (RollbackException | HeuristicMixedException | HeuristicRollbackException | IllegalStateException | NotSupportedException | SystemException ex) {
Logger.getLogger(IslemEJB.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(ex);
mesaj = "Hata : Güncelleme işlemi sırasında hata meydana geldi. ";
durum = false;
}
catch (SecurityException ex) {...}
@无状态
@TransactionManagement(TransactionManagementType.BEAN)
公共类IslemEJB{
@PersistenceContext(unitName=“etobsentinelpu”)
私人实体管理者;
@资源
私有用户事务;
私人T;
私立大学;
公共T updateMessageSizWithReturn(T){
试一试{
ut.begin();
t=em.merge(t);
em.flush();
System.out.println(“日志id”+t);
ut.commit();
}
catch(RollbackException | HeuristicMixedException | HeuristicRollbackException |非法状态异常| NotSupportedException | SystemException ex){
Logger.getLogger(IslemEJB.class.getName()).log(Level.SEVERE,null,ex);
系统输出打印项次(ex);
mesaj=“Hata:Güncelleme işlemi sırasında Hata meydana geldi。”;
硬粒=假;
}
catch(SecurityException ex){…}
并且错误是在应用程序启动时未完成事务而返回的无状态会话Bean方法。您可以共享
catch
块吗?因为在em.flush()
期间可能会出现RuntimeException
,在这种情况下不会调用ut.commit()
。}catch(RollbackException | HeuristicMixedException | HeuristicRollbackException | IllegalStateException | NotSupportedException | SystemException ex){Logger.getLogger(IslemEJB.class.getName()).log(Level.severy,null,ex);System.out.println(ex);mesaj=“Hata:Güncelleme işlemi sırasıHata meydana geldi。”;durum=false;}catch(SecurityException ex){
您可以共享您的catch
块吗?因为在em.flush()
期间可能会出现RuntimeException
,在这种情况下,不会调用ut.commit()
。}catch(RollbackException | HeuristicMixedException | HeuristicRollbackException | IllegalStateException | NotSupportedException | SystemException ex){Logger.getLogger(IslemEJB.class.getName()).log(Level.severy,null,ex);System.out.println(ex);mesaj=“Hata:Güncelleme işlemi sırasıHata meydana geldi。”;durum=false;}catch(SecurityException ex){