Just make it an APPLICATION scoped Seam component. You can use the @Startup annotation to ensure it gets instantiated during the startup cycle. Retrieve the data in an @Create method.
Thanks for your help Gavin.
I followed you and made a seam component(not a stateful or stateless bean) with following annotations:
this works fine but I can't inject @PersistenceContext EntityManager anymore, it seems I can only inject EntityManager in a stateful or stateless ejb. Since I need to retrive data in my @Create method, I need to inject an EntityManager or another ejb using @Ejb. I've tried both way but non of them work. Is there any better to do this?
Problem solved by use:
InitialContext ctx = new InitialContext();
The other option is to use a seam-managed EntityManager.
@PersistenceContext only works in an EJB.
I have the exact same issue here, however not sure how to use the seam-Managed EM.
Just to be sure, is it the one in: "13.4.2. Using a Seam-managed persistence context" from the Seam Ref Doc 1.1.CR2 ?
I've tried (as per ref) to add it to the components.xml, no luck
<core:managed-persistence-context name="bookingDatabase" auto-create="true" persistence-unit-jndi-name="java:/EntityManagerFactories/bookingData"/>
The DTD for components.xml does not seem to like the 'core' tag, or is the Documentation incorrect ?
Any pointers will be helpful !
You must use XSDs, not a DTD. Look at the booking example to see how.
Indeed, that's clear now.
Maybe I've got the DTD definition (and the error) as I was using a scaffolded Entity from SeamGen.
Thanks for your promptly assistance!
Ignore my last comment, I've just confirmed it's fixed in CVS in 1.5