On Apr 22, 2008, at 10:51 AM, wesley wrote: > So singleton beans will also got a lazy load after DataSource, right?
It should, but the logic is sufficiently complicated that there might be a case that's not working. The current code basically has three phases: 1. configuration and class-enhancement 2. binding 3. startup The configuration/class-enhancement is the trickiest phase, since it may involve bytecode enhancement. If a class that needs enhancement (like JPA) gets loaded too soon, it can't be properly bytecode-enhanced. The configuration phase will also register any webbeans, and configure/ register the DataSource. The binding phase is when the dependency injection gets resolved. Because the beans are already registered (in phase #1), circular references will work. Finally, the startup phase initializes servlets, listeners, singletons, etc. So singletons will be resolved after the DataSource is configured. > Thanks, Scott. > > ps. Do you have time to look at my previous post about how to config > jca > connection pool max-active-time? Yep. My response should have crossed yours on the list. -- Scott > > > ----- Original Message ----- > From: "Scott Ferguson" <[EMAIL PROTECTED]> > To: "General Discussion for the Resin application server" > <resin-interest@caucho.com> > Sent: Tuesday, April 22, 2008 10:35 PM > Subject: Re: [Resin-interest] <database> config should be initialized > beforeany singleton beans > > >> >> On Apr 22, 2008, at 2:45 AM, wesley wrote: >> >>> Hi Scott, >>> >>> I'm upgrading snap080331 to snap080417. I found my hibernate >>> persistence unit not >>> working, with no jta-data-source configured. >>> I added 080417 src into my project and traced for a while and found >>> the reason. >> >> This is something I worked on yesterday. The next snapshot should >> have the fix. >> >> The fix involves making the persistence.xml lookup of the dataSource >> lazy, so it only occurs using web-app start time, not at >> persistence.xml start. >> >> -- Scott >> >>> >>> >>> I put an breakpoint at com.caucho.naming.Jndi.bindImpl(...) line:91 >>> and recorded >>> the jndi resources registered at order below: >>> "java:comp/env/jmx/MBeanServer" ... >>> "java:comp/env/jmx/GlobalMBeanServer" ... >>> "java:comp/UserTransaction" ... >>> "java:comp/TransactionManager" ... >>> "java:/TransactionManager" ... >>> "java:comp/ThreadPool" >>> "java:comp/env/caucho/persistent-store" >>> and then my singleton beans were then initialized, then >>> "java:comp/env/jdbc/stock" // my <database> config in resin- >>> web.xml >>> "java:comp/env/activemq" // my <connection-factory> config >>> in resin-web.xml >>> >>> Some of singleton beans need to access database by inject a EMF, so >>> amber start to >>> load persistence unit. During parsing the persistence.xml, the xml >>> config will set the >>> "jta-data-source" property of the >>> com.caucho.amber.cfg.PersistenceUnitConfig object >>> by reflection. Before doing it, it will call JNDI.lookup to find the >>> DataSource with name >>> specified in persistence.xml, of cource nothing found! It was not >>> registered yet! >>> >>> I switched to snapshot080331 binary and still retained some src of >>> 080417 (src package: >>> com.caucho.amber, com.caucho.config, com.caucho.naming) then traced >>> it again. >>> This time I recored the the jndi resources registered at order below >>> "java:comp/env/jmx/MBeanServer" ... >>> "java:comp/env/jmx/GlobalMBeanServer" ... >>> "java:comp/UserTransaction" ... >>> "java:comp/TransactionManager" ... >>> "java:/TransactionManager" ... >>> "java:comp/ThreadPool" >>> "java:comp/env/caucho/persistent-store" >>> "java:comp/env/jdbc/stock" // my <database> config in resin- >>> web.xml >>> "java:comp/env/activemq" // my <connection-factory> config >>> in resin-web.xml >>> and then my singleton beans were then initialized. >>> This is the right sequence. >>> >>> Though I didnot do further test, I think problem were not belonged >>> to the three packages >>> I retained during the two snapshot version switch. >>> >>> Suggestions are appreciated, thanks. >>> >>> -Wesley >>> >>> >>> _______________________________________________ >>> resin-interest mailing list >>> resin-interest@caucho.com >>> http://maillist.caucho.com/mailman/listinfo/resin-interest >> >> >> >> _______________________________________________ >> resin-interest mailing list >> resin-interest@caucho.com >> http://maillist.caucho.com/mailman/listinfo/resin-interest >> > > > > _______________________________________________ > resin-interest mailing list > resin-interest@caucho.com > http://maillist.caucho.com/mailman/listinfo/resin-interest _______________________________________________ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest