I make it that way:
Code:
//First create the EJB3 Configuration
Ejb3Configuration config = new Ejb3Configuration();
//set the properties of my configuration
config.setProperties(p);
//add all POJOs to the configuration
ArrayList<Class> classes = (ArrayList<Class>)getPOJOs();
for (Class c : classes) {
config.addAnnotatedClass(c);
}
//build the entityManagerFactory from my ready config
EntityManagerFactory factory =
(EntityManagerFactory)config.createEntityManagerFactory();
what I don't understand from your code:
1) You build a propertyMap, but doesn't use it anywhere
2) You get your EntityManagerFactory from the Persistence. What is Persistence?