记得ejb有个设置tansaction的地方,如果required的话,
ejb containner自己处理事务的提交回滚,你查查你的设置

解决方案 »

  1.   

    Connection.commit这个方法不要用
      

  2.   

    如果你的ejb事务是容器管理的。Connection.commit或rollback是不能用的
      

  3.   

    现在改成bean管理的!s式无状态的!try
        {
          UserTransaction ut = sessionContext.getUserTransaction();      Call_updateSQL(bufSql.toString());      String sq1 = "inset into MS_USER_VERIFY(ID) values ('www')";
          Call_updateSQL(sq1);
          ut.begin();
          ut.commit();
        }catch(Exception ex)
        {
          try
          {
              UserTransaction ut = this.sessionContext.getUserTransaction();
              ut.rollback();
          }catch(Exception e)
          {
            System.out.println("The rollback error is"+e);
          }
          System.out.println("The commit error is"+ex);
          return;
        }    }
    现在错误如下:
    The rollback error isjava.lang.IllegalStateException: Transaction does not exist
      

  4.   

    UserTransaction ut = null;
    try
        {
           ut = sessionContext.getUserTransaction();
          ut.begin();
          Call_updateSQL(bufSql.toString());      String sq1 = "inset into MS_USER_VERIFY(ID) values ('www')";
          Call_updateSQL(sq1);
          
          ut.commit();
        }catch(Exception ex)
        {
          try
          {
              ut.rollback();
          }catch(Exception e)
          {
            System.out.println("The rollback error is"+e);
          }
          System.out.println("The commit error is"+ex);
          return;
        }    }这样应该可以了
      

  5.   

    不行呀!
    The commit error is java.lang.NullPointerException
    现在式这个!
      

  6.   

    主要还是这个错误!
    java.lang.IllegalStateException: Transaction does not exist
      

  7.   

    try{
          System.out.println(bufSql.toString());
          UserTransaction ut = sessionContext.getUserTransaction();
          ut.begin();
          Call_updateSQL(bufSql.toString());
          ut.commit();
        }catch(Exception ex)
        {
          try
          {
              UserTransaction ut = sessionContext.getUserTransaction();
              ut.rollback();
              throw ex;
          }catch(Exception e)
          {
            System.out.println("The rollback error is"+e);
          }
          System.out.println("The commit error is "+ex);
        }
      

  8.   

    错误
    The rollback error isjava.lang.NullPointerException
    The commit error is java.lang.NullPointerException
      

  9.   

    我觉的你可能没设置成bean管理
      

  10.   

    try{
          System.out.println(bufSql.toString());
          UserTransaction ut = sessionContext.getUserTransaction();
          ut.begin();
          Call_updateSQL(bufSql.toString());
          ut.commit();
        }catch(Exception ex)
        {
          try
          {
              ex.printStack();
              if (ut!=null)        ut.rollback();
              throw ex;
          }catch(Exception e)
          {
            System.out.println("The rollback error is"+e);
          }
          System.out.println("The commit error is "+ex);
        }
      

  11.   

    奇怪了,我使用UserTransaction这种方式进行commit/rollback操作是不成功的。而直接使用connection的commit/rollback确是好用的。我创建的ejb是无状态的session bean(基于bean管理的)。我想你还是看看你原先的程序哪个地方写的不对吧。
      

  12.   

    我想只要你配置成基于bean管理的就应该可以使用connection的commit/rollback了。你好好试一下,不知道为什么使用UserTransaction这种方式不行。
      

  13.   

    从那个错误来看,还是会话bean的状态的问题啊,为什么说是非法的state 呢