-
Spring, Hibernate and EJB (3 messages)
- Posted by: guddu sk
- Posted on: March 25 2008 04:10 EDT
Hi, I am using EJB container and having Spring configuration and Hibernate as well. How can I use Spring and load SessionFactory of Hibernate in EJB Container, knowing quite well that filter and servlet context loader will not work in ejb container? Please help. Thanks, Guddu http://freesourceutilityhelp.googlepages.com/Threaded Messages (3)
- Re: Spring, Hibernate and EJB by sridhar r on March 25 2008 19:57 EDT
- Re: Spring, Hibernate and EJB by guddu sk on March 26 2008 01:01 EDT
- Re: Spring, Hibernate and EJB by James Roper on March 28 2008 09:39 EDT
-
Re: Spring, Hibernate and EJB[ Go to top ]
- Posted by: sridhar r
- Posted on: March 25 2008 19:57 EDT
- in response to guddu sk
Hi, I think i understood what you mean. You have set of spring config files which you want to have it loaded in EJB container. Had you had a web container, you should have been able to load through startup servlet/web.xml. In case of just alone a EJB container, i think you can use static block of code to initialize the spring config files. Regards, Sridhar -
Re: Spring, Hibernate and EJB[ Go to top ]
- Posted by: guddu sk
- Posted on: March 26 2008 01:01 EDT
- in response to guddu sk
knowing quite well that filter and servlet context loader will not work in ejb container?
I think filter and servlet context loader may not be used in EJB container, and where can I use static code for loading applicationContext.xml file and how? Thanks in advance. Guddu http://freesourceutilithelp.googlepages.com -
Re: Spring, Hibernate and EJB[ Go to top ]
- Posted by: James Roper
- Posted on: March 28 2008 09:39 EDT
- in response to guddu sk
The Spring Reference Guide has a chapter on exactly how to do this: http://static.springframework.org/spring/docs/2.5.x/reference/ejb.html#ejb-implementation Basically, I'll assume you're using EJB 2.x stateless session beans, so your EJB should extend AbstractStatelessSessionBean, and then in your ejb-jar.xml file you specify an resource environment variable, at "ejb/BeanFactoryPath", that references the path to your spring configuration file. For example: ejb/BeanFactoryPath java.lang.String applicationContext.xml Note that applicationContext.xml must be in the EJB containers classpath, that is, it can't be in the WEB-INF folder of a web app.