• No replies
2 Posts

Pinned topic @EJB annotation vs JNDI lookup + transaction

‏2013-09-09T07:00:04Z |

I think there's no difference between invoking a session EJB via JNDI lookup and using the @EJB annotation. However, in the following scenario:

1.- call session EJB1(JDBC inserts here) 2.- From EJB1, call session EJB2 (more inserts here) 3.- Rollback the transaction (from EJB1)

If I use the @EJB annotation it works fine, but with the JNDI lookup it doesn´t, the transaction in the second EJB is a new one and the rollback doesn´t happen. All this with CMT.

I'm deploying all this stuff in a Geronimo/ibmwasce-

¿Do I need to pass the transaction from one EJB to another explicitly? I thought it was the continer job. ¿Any clues?


Code via annotation:

private CodAppEjb codAppejbAnotacion;

Code via JNDI

CodAppEjb codAppejb;
InitialContext ctx;
Properties properties= new Properties();
properties.setProperty("java.naming.provider.url", "ejbd://");
properties.setProperty("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
ctx = new InitialContext(properties);
codAppejb= (CodAppEjb) ctx.lookup("CodAppEjbBeanRemote");
Updated on 2013-09-09T07:31:10Z at 2013-09-09T07:31:10Z by onoffre