0 Replies Latest reply on Mar 17, 2002 8:26 AM by billhuangyu

    Transaction Warning and 100% cpu usage!

    billhuangyu Newbie

      I am new about the transactions, when I run my EJB program I got a warnning and cpu 100% usage.

      I program is something like this.
      I have a session bean A which can be call by client, all methods are using transaction type "required". I have an entity bean B, which called by session bean A with all method specified as required.

      I have a method in bean A like below:
      public void assignSameRoleAs(java.lang.String user,java.lang.String templateUser)
      {
      if (!user.equals(templateUser))
      {
      try
      {
      InitialContext initial=new InitialContext();
      UserHome userHome=(UserHome)initial.lookup("ejb/User");
      User userObject=userHome.findByPrimaryKey(user);
      userObject.addRoleTypeAsUser(templateUser);

      }
      catch(javax.naming.NamingException ne)
      {
      System.out.println("ejb/User or ejb/Role is not found, ejb/User or ejb/Role is not bound to User bean");
      throw new EJBException(ne);
      }
      catch(javax.ejb.FinderException fe)
      {
      System.out.println("The user or role object specified is not found in the system!");
      throw new EJBException(fe);
      }
      }
      }

      and has a method in Entity bean B like below:

      public void addRoleTypeAsUser(java.lang.String username) throws EJBException
      {
      try
      {
      InitialContext initial=new InitialContext();
      UserHome userHome=(UserHome)initial.lookup("ejb/User");
      User srcUser=userHome.findByPrimaryKey(username);
      Collection srcRoleTypes=srcUser.getRoleType();
      Collection targetRoleTypes=this.getRoleType();
      targetRoleTypes.addAll(srcRoleTypes);
      }
      catch(FinderException fe)
      {
      System.out.println("This user specified is not found");
      throw new EJBException(fe);
      }
      catch(javax.naming.NamingException ne)
      {
      System.out.println("Cannot find the specified User");
      throw new EJBException(ne);
      }
      }

      When client program call the method from session bean A, the machine prompt up the warning message like below, and 100% cpu usage in the computer.

      Do anyone can help me this and tell me why this happened so I will not make the same mistake in the future.

      13:09:10,382 WARN [TxCapsule] Transaction XidImpl [FormatId=257, GlobalId=bill/
      /6, BranchQual=] timed out. status=STATUS_ACTIVE