1 Reply Latest reply on Apr 3, 2007 11:14 AM by William DeCoste

    how to realize distributetransaction between 2 containers?

    gavin lu Newbie

      There are two jboss servers, and there is on EJB A and EJB B in server A, there is one EJB C in server B,I want to invoke EJB B and C in EJB A, and I would like to make them in one transaction, code list, but it throw exceptions:

      Properties localProps = new Properties();
      //localProps.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      //localProps.setProperty("java.naming.provider.url", "iiop://localhost:1099");
      //localProps.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
      InitialContext localContext = new InitialContext(localProps);

      //Properties remoteProps = new Properties();
      //remoteProps.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      // remoteProps.setProperty("java.naming.provider.url", "iiop://10.1.16.38:1099");
      // remoteProps.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
      // InitialContext remoteContext = new InitialContext(remoteProps);
      UserTransaction trans = (UserTransaction) localContext.lookup("UserTransaction");
      try {
      trans.begin();

      // Member member = (Member) localContext.lookup("MemberBean/remote");
      // PotentialMemberEntity memberEntity = new PotentialMemberEntity();
      // memberEntity.setMobilenumber("13811111111");
      // member.addPotentialMember(memberEntity);

      BoothMember boothMember = (BoothMember) localContext.lookup("corbaname:iiop:1.2@qbh:3528#BoothMemberBean/remote");
      BoothMemberKindEntity kindEntity = new BoothMemberKindEntity();
      kindEntity.setBoothid(1L);
      kindEntity.setKindtitle("QbhTest");
      boothMember.addMemberKind(kindEntity);

      trans.commit();
      } catch (Exception e) {
      trans.rollback();
      throw e;
      }