Hey Borislav, a couple of additional notes if you want. As Romain mentioned, the spec only authorize global JNDI names from the EJBContainer global context. Check out the logs. OpenEJB/TomEE outputs the JNDI names so that you don't have to guess.
Regarding your code, you are defining default annotations. I mean, container managed transaction is the default so you don't need to add it, as well as the REQUIRED transaction behavior. The ejb-jar.xml is no more required since EJB 3.0 in most of the cases. Even the local interface is not required if you don't plan to have more implementations. So basically, having just @Stateless should work. Jean-Louis -- Jean-Louis Monteiro http://twitter.com/jlouismonteiro http://www.tomitribe.com On Mon, Nov 17, 2014 at 9:56 PM, Romain Manni-Bucau <[email protected]> wrote: > Hi > > EJBContainer.createEJBContainer(p).getContext(); only provides global > naming by spec > > > Romain Manni-Bucau > @rmannibucau > http://www.tomitribe.com > http://rmannibucau.wordpress.com > https://github.com/rmannibucau > > > 2014-11-17 21:43 GMT+01:00 [email protected] > <[email protected]>: > > Hi all, > > > > I'm new to OpenEJB and I'm trying to learn with a small made up example. > > Specifically, I have 1 stateless bean that I want to give a local ejb > > reference and be able to perform a JNDI lookup on that reference. So I > have > > a Java interface, its implementation, an META-INF/ejb-jar.xml and a main > > program. My problem is that the lookup by the local reference name > fails. > > Here are my short files: > > > > DataRepo.java > > > > @Local > > public interface DataRepo > > { > > List<Point> getInterestingPoints(); > > } > > > > DataRepoImpl.java > > > > @Stateless( name = "dataRepo" ) > > @TransactionManagement( value = TransactionManagementType.CONTAINER ) > > @TransactionAttribute( value = TransactionAttributeType.REQUIRED ) > > @LocalBean > > public class DataRepoImpl implements DataRepo > > { > > @Override > > public List<Point> getInterestingPoints() > > { > > return null; > > } > > } > > > > main program: > > > > { > > Properties p = new Properties(); > > final Context context = > > EJBContainer.createEJBContainer(p).getContext(); > > DataRepo repo = > > (DataRepo)context.lookup("java:comp/env/ejb/TheRepo")); > > } > > > > <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"> > > <enterprise-beans> > > <session> > > <ejb-name>dataRepo</ejb-name> > > <ejb-local-ref> > > <ejb-ref-name>ejb/TheRepo</ejb-ref-name> > > <local>optimus.DataRepo</local> > > </ejb-local-ref> > > </session> > > </enterprise-beans> > > </ejb-jar> > > > > I can find the ejb from its auto-constructed "java:global/..." name. I'm > > also sure that ejb-jar.xml is taken into consideration because when I > > purposefully introduce an error in it OpenEJB complains. > > > > What am I doing wrong? Why is my ejb-ref-name ignored here? > > > > Thanks much in advance! > > > > Best, > > Boris > > > > > > > > -- > > View this message in context: > http://tomee-openejb.979440.n4.nabble.com/using-local-ejb-reference-in-the-embedded-container-tp4672896.html > > Sent from the TomEE Users mailing list archive at Nabble.com. >
