Reusing EJBs outside J2EE
Since Entity Beans and Session Beans can be coded as POJOs, I figured that it should be possible to write code that works both inside and outside the J2EE container. As a first step to trying this out, I am building a small demo that consists of:
1. The Entities packaged in a jar file.
2. The Session beans packaged in another jar file.
3. An EAR containing above and deployed to Glassfish server.
4. A client application that attempts to access a session bean using J2EE application client interface.
5. A client application that accesses the same session bean but from a regular J2SE environment using application managed Persistence.
My first question: where should I place the persistence.xml file? I have it in the entity jar file but this is causing a problem when I invoke the J2EE application client - the dependency injection in the session bean fails.
My second question: The persistence.xml is supposed to contain "class" entries when used outside of container. However, if these entries are present when attempting to deploy in Glassfish, I get an exception. Why can't Glassfish simply ignore the "class" entries?