This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sharing of Persistence Context - Multiple WAR

 
Juggy Obhi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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,
Jagpreet Singh
 
Juggy Obhi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ntumba lobo
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Juggy Obhi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
ntumba lobo
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic