[jboss-user] [EJB 3.0] - how to realize distributetransaction between 2 containers?

lugibin do-not-reply at jboss.com
Tue Apr 3 03:51:51 EDT 2007


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 at 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;
}

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033909#4033909

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033909



More information about the jboss-user mailing list