I need your help to know a good structure for the 3 Web Applications i am working on...
core - Web Application to serve a Mobile Phone Application (Consists mainly Servlets)
front - Front End Web Application for the Users (Struts/Spring based)
back - Back End Web Application for the Admin(Struts/Spring based)
All of these Apps uses following JARS -
commons - Project containing common Util classes, Exceptions etc - JAR persistence - Project containing the JPA entity classes and the persistenceContext.xml under /META-INF - JAR
At present, I copy paste these two JARS in the /lib folder of my Web Apps and as a result, 3 different Persistence Contexts gets created despite it is the same, I want to share both of these jars among my Web Apps. I want a single shared Persistence Context to exist. How can i achieve this?? Please guide.
Thanks and Regards,
It does not matter how many times you fall,what matters is how many times you stand back.
Joined: Jul 02, 2007
Juggy Obhi wrote:
Note: I am Using TOMCAT 7 as the Server so i doubt if EAR is an option for me.
I really need help. I can see big issues with the way my apps are, alomost every thing is common with these three apps, but at this times, unwillingly i have to duplicate all my jars in all three apps along with the duplication of persistence context at three places. I see same persistence context loading 3 times when i start my tomcat server. Please guide me.
you have options if your 3 web applications are deployed in the same application server
a) package the 3 webapp in an ear file and put your persistence jar in the common lib folder of the ear
b) put your persistence jar the server classpath that is shared by all deployed application
Note that is option a) is a much better approach to me
SCJP 5 , SCWCD 5, SCEA 5
Joined: Jul 02, 2007
Thanks ntumba lobo!
I agree that option A is a better approach but can i deploy an EAR to Tomcat? I read somewhere that it is not possible.
I tried option B, i placed my persistence jar in Tomcat/lib but then i got ClassNotFoundExceptions.
I am still stuck
Joined: Oct 21, 2008
Sorry I didnt see you were using Tomcat. That's correct you cant use an ear file with a servlet container.
As for your ClassNotFoundException that's odd, the tomcat/lib folder should be visible to both server and webapp as far as I remember.
Can you give more details about the error if you havent solved your pb yet ?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Sharing of Persistence Context - Multiple WAR