I've come across elements of these problems in various google searches but I've been at it so long now my brain is starting to melt.
Using: JBoss 7.1.1 (and the bundled Hibernate + Resteasy), running on Java 6.
We have the following elements split across multiple maven modules:
[server-common] (JAR) StudyRemote (@Remote EJB interface)
[server-beans] (JAR) persistence.xml StudyBean (@Stateless implementation of StudyRemote interface)
[website] (WAR) IStudyAPI (interface JAX-RS annotations and @Local) StudyAPI (@Stateless implementation of IStudyAPI)
in essence, the StudyBean/StudyRemote act as a DAO.
We have two possible deployment scenarios: 1) server-common, server-beans and website are all bundled into an EAR file 2) server-common and server-beans are bundled into an EAR and website.war is deployed afterwards Under both scenarios, the issue is that I'm getting LazyInitializationException in the StudyAPI methods. It seems the hibernate session is only lasting as long as the method calls within the StudyBean. That is, getStudy(id) will return a Study entity, but then trying to access lazy members does not work.
Ideally I'd like all of the EntityManager work to be done within the StudyBean implementation (i.e. I'd like to try and avoid EntityManager references in the StudyAPI implementation) but have the hibernate session exist for the duration of an HTTP call such that I can access the lazy members of the objects returned by the StudyBean methods. Is there some kind of explicit demarcation I can do?
I'm hoping the issue is one I can read up on and learn the hows and whys of glueing together these components, I'm just a bit deluged with information when I google the issue :(
Thanks, Derek
|