Mar 18th, 2011, 12:09 PM
Roo Entities and Glassfish?
I'm trying to get the skeleton together for a Roo DBRE generated Domain model in a J2EE app. I've been making progress, but ran into a stumper.
My app (using Eclipse and STS plugins) has:
PlusDomain: The generated DBRE entities.
PlusEJB: EJB Handlers to access Entities.
PlusEJBClient: Interface code for EJBs.
PlusWeb: Simple web tier, with one servlet, that uses @EJB to lookup handler from PlusEJB.
PlusEAR: The EAR wrapping the other components.
I'm having big problems with persistence context injection. When Roo first generates an entity, it places a @PersistenceContext annotation around an EntityManager field in the *_Roo_Entity.aj file. This didn't work with Glassfish, because it seems Glassfish makes some assumptions about field or method names (which get mangled up by AspectJ), and deployment would fail. The fix there was to copy the persistence context declaration into the generated entity class file. This causes the Roo Entity add-on to regenerate the *_Roo_Entity.aj file without the persistence context field, and the project now deploys.
However, even though it seems that the bean validation is now passing and the container should be able to find the field to inject the entity manager, I'm getting this error:
Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)
So, what's necessary to get the persistence context injected into an entity in Glassfish 3.0.1? I'm using Hibernate as my persistence provider. I'm suspecting that Spring may not actually be starting, and therefore the @Configurable support, but I'm lost trying to figure out where to go next.
As far as the general app structure is concerned, my servlet is working, my ejb injection at the servlet level is working, and my stack trace is showing that the call got from my EJB into the *_Roo_Entity.aj code before bombing out.
Last edited by dsp; Mar 18th, 2011 at 12:14 PM.
Mar 18th, 2011, 03:19 PM
Would be easier for you just reverse engineer your db using the STS JPA project?... and use the glassfish development stack.
It seems DBRE is the only functionality you are after by using Roo. Right?
Hopefully makes it make sense to you.
Mar 18th, 2011, 11:15 PM
Not at all
No, I'm interested in using as much Roo as I can manage. I'm starting with DBRE to get access to my exisiting data, then I plan to use the GWT integration to craft a new front end.
Mar 21st, 2011, 09:38 AM
I finally got it working. The missing piece was Spring. I added Spring libraries and set up a minimal configuration in my webapp, added the stuff from the Roo generated applicationContext.xml, and now it works.
I missed this originally because I never used Spring before, and didn't understand how it related to Roo.
Last edited by dsp; Mar 21st, 2011 at 09:44 AM.