On Oct 15, 2008, at 10:13 AM, Jan Kriesten wrote: > > Hi, > > I'm currently a bit puzzled since I don't get to work what yesterday > has already. > > As I understand it should be possible to lookup an > EntityManagerFactory via JNDI as > > java:comp/env/persistence/PersistenceUnit/xxx
The official JavaEE JNDI system is really weird. (I believe it's getting changed for JavaEE 6, but that spec is still in early draft.) Technically, the persistence.xml scanning does not automatically populate JNDI with the EntityManager. It populates an app-server dependent space (in Resin it's WebBeans) that's available for injection using @PersistenceUnit and @PersistenceContext. If you have a @PersistenceUnit or @PersistenceContext (or <persistence- unit> or <persistence-context> in your web.xml), those declarations populate the JNDI space with their JNDI name. So you're technically missing a JNDI linking step. Personally, I'd stick with the injection annotations when possible and avoid JNDI, since JNDI is really a previous-technology solution. -- Scott > > > - but I just can't get that to work. > > My persistence.xml has > > <persistence-unit name="DomainRegistryService"> > <class>de.footprint.domreg.persistence.entities.Rezept</class> > <class>de.footprint.domreg.persistence.entities.Zutat</class> > <exclude-unlisted-classes /> > </persistence-unit> > > in it. resin-web.xml contains: > > <ejb-server entity-manager-jndi-name="DomainRegistryService"> > <data-source>jdbc/DomainRegistryServiceDS</data-source> > </ejb-server> > > The data-source is defined as well, so everything should be fine. > > But starting the application gives me: > > [18:56:46.431] Compiling > de/footprint/domreg/persistence/entities/Rezept__ResinExt.java > [18:56:46.431] Compiling > de/footprint/domreg/persistence/entities/Zutat__ResinExt.java > [18:56:47.819] Note: > /usr/local/www/services/domreg/html/WEB-INF/work/pre-enhance/de/ > footprint/domreg/persistence/entities/Rezept__R > esinExt.java uses unchecked or unsafe operations. > [18:56:47.819] Note: Recompile with -Xlint:unchecked for details. > [18:56:47.860] Amber enhancing class > de.footprint.domreg.persistence.entities.Rezept > [18:56:47.922] Compiling > de/footprint/domreg/persistence/entities/Rezept__ResinExt.java > [18:56:48.567] Note: > /usr/local/www/services/domreg/html/WEB-INF/work/pre-enhance/de/ > footprint/domreg/persistence/entities/Rezept__R > esinExt.java uses unchecked or unsafe operations. > [18:56:48.567] Note: Recompile with -Xlint:unchecked for details. > [18:56:48.697] Amber enhancing class > de.footprint.domreg.persistence.entities.Zutat > [18:56:48.730] Compiling > de/footprint/domreg/persistence/entities/Zutat__ResinExt.java > 18:56:50.438 INFO [reg.web.application.DomainRegistryApplication] - > Application > init... > 18:56:50.542 INFO [application.DomainRegistryApplication$$anon$1] - > Configuring > application bindings... > javax.naming.NameNotFoundException: > java:comp/env/persistence/PersistenceUnit/DomainRegistryService > Manual EMF > > Which means that looking up the PersistenceUnit doesn't work. I can > manually > create the EntityManagerFactory with > > Persistence.createEntityManagerFactory( "DomainRegistryService" ) > > though. Queries are running with the manual setup (only lazy fetches > aren't > resolved this way!). > > I'm running resin 3.1.7 pro. > > Can someone give me a hint what I'm doing wrong?! Also - when I > change the > persistence-provider to eclipselink, will Amber put then the created > EntityManagerFactory also into the JNDI context? > > Thanks in advance! > > Best regards, --- Jan. > > > > > _______________________________________________ > resin-interest mailing list > [email protected] > http://maillist.caucho.com/mailman/listinfo/resin-interest _______________________________________________ resin-interest mailing list [email protected] http://maillist.caucho.com/mailman/listinfo/resin-interest
