10 Replies Latest reply: Jan 17, 2011 11:05 AM by Michael Musgrove RSS

How to propagate a transaction from one EJB3 to another EJB on JBoss.

ShuiXin Zhang Newbie

Hi,

I know there is a article to describe the transaction propagation, but I failed to run the case.

What I missing to enable the JTS? I use JBoss 5.1.0 GA. Can you help?

 

  1. I enabled the JTS by executing ant command %JBOSS_HOME%\docs\examples\transactions. The jbossts-properties.xml is also copied correctly. I compared it with %JTS_EXAMPLE%\resources\jbossjts-properties.xml, and copied some different properties to %JBOSS_HOME%\server\all\conf\jbossjts-properties.xml file.
  2. I deploy a EJB3 project, which will invoke another EJB2 method, I use the below code:

            Properties properties = new Properties();
            String url = "corbaloc::localhost:3528/JBoss/Naming/root";
            String fac = "com.sun.jndi.cosnaming.CNCtxFactory";


            properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, fac);
            properties.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client:org.jnp.interfaces");
            properties.setProperty(Context.PROVIDER_URL, url);


            InitialContext ctx = new InitialContext(properties);
           
            Object o = ctx.lookup("HelloWorld");
            HelloWorldHome hwHome = (HelloWorldHome) PortableRemoteObject.narrow(o, HelloWorldHome.class);
            HelloWorld hw = hwHome.create();
            String s = hw.sayHello("hello");

   The exception is thrown:

15:21:00,088 ERROR [STDERR] javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
15:21:00,088 ERROR [STDERR]     at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:44)
15:21:00,088 ERROR [STDERR]     at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:485)

 

If I invoke another EJB3, there is the same problem.