I want to create some sample code for JPA2 that can be run inside a Java EE container.
Running those sample normally require to have a Java EE server but i want to make things easier and to run them using an embedded container + maven.
Which one is better for this kind of “project” ?
Glassfish embedded , JBoss microcontainer or OPENEJB ?
Others ?
Thank you !
The problem to test EJB outside a container is that injections are not performed. I found this solution. In the stateless session bean you have an annotation @PersistenceContext
in a standalone Java-SE environment you need to inject the entitymanager by yourself, whcih can be done in an unittest. This is a fast alternative to an emmbeded server.
The unittest instantiates the entitymanager and ‘injects’ it into the bean.