I have a servlet running in an Oracle OCCAS server. Currently I map some data in a database to an entity class in my application using @Entity annotaion. I fail to inject the EntityManager (@PersistenceContext) though, and to my understanding that is because it is running in my servlet context and not as a separate Entity EJB. Creating the manager through the EntityManagerFactory works, though, so that is what I use at the moment.
Now, after a number of restarts of the application, I get an out of PermGen space error. I figure this is related to the persistence somehow. There is a call to EntityManager.close() in my finalize method, but it never shows up in the log.
Is this a Bad Way of doing things - am I "required" to have a separate Entity Bean, or how am I supposed to clean up the EntityManager?