Spring, Hibernate and EJB

Discussions

EJB design: Spring, Hibernate and EJB

  1. Spring, Hibernate and EJB (3 messages)

    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)

  2. Re: Spring, Hibernate and EJB[ Go to top ]

    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
  3. Re: Spring, Hibernate and EJB[ Go to top ]

    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
  4. Re: Spring, Hibernate and EJB[ Go to top ]

    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.