My application comprises three layers being:
- Interaction layer (RestServices JAX-RS)
- Business layer (Stateless EJBs)
- Persistence layer (DAO's with queries etc.)
In addition I have this domain objects layer which runs through the layers. The application was first setup to use a nosql database, but we had to abandon that. Now we are using JPA with a RDBMS but running into trouble when migrating, mainly due to the fact that the jaxb objects that the interaction layer is using, is trying to lazily load domain objects without a transaction when the are serialized. This transaction has been closed once it returned from the stateless ejb.
After reading a lot on the web, I tried to annotate my restservice with @Stateless too in order to start a transaction a bit sooner and to avoid the transaction being closed once the business layer has been left. Unfortunately this doesn't work either as I still getting lazilyinitializationexceptions.
So my question is how should I combine JAXB, JAX-RS and EJB's in order to avoid the LIException?
regards
Michael