开发者

Repackage several WARs into one EAR

I'm working on a project that have several webapps (WARs) built with Maven and deployed in a Java EE.

These WARs share several common business JARS (like one containing domain objects which are loaded from hibernate) and other framework JARs like Spring and Hibernate.

They use Spring MVC, and the Application Context loads Hibernate. As each WAR has its 开发者_运维知识库own Classpath in the servlet container, the Hibernate cache (EHcache) is not shared.

What I'd like is to share the cache and also the hibernate session factory bean (as well as other common beans) betweeen the different WARs. I think this is possible by repackaging those WARs inside an EAR and then I'd have to make a spring configuration XML using those commons beans and in the WAR's Spring XML use something like SingletonBeanFactoryLocator from what I've read.

What I'm asking here is if there is a simple way to do this, minimizing changes to the WARs' POMs

Note: I'm familiar with WARs, tomcat and servlets, but not so much with EARs.

Thanks in advance.


Hmmm... Most Java EE containers use isolated classloaders for WARs, even in an EAR (even if the Java EE spec does not mandate class loading isolation among modules of a single EAR) so I wouldn't expect to much from an EAR packaging, especially if you want your application to remain portable (i.e. if you don't want to rely on any app server specific behavior).

Now, if really it makes sense to share your session factory and your 2nd level cache between several applications, maybe consider merging them in a single WAR. That would be the easiest way IMO. But I'd be tempted to ask why are they separate then? When applications are separate, they have most of time separate governance and I don't know if deploying them together would be a good idea in such case.

And if merging the WARs is not an option, please tell us which container you are using.


Have you considered making use of a coherent clustered L2 cache? If you're using multiple app servers you might see more benefit then as they would all be sharing the same coherent cache


Using a shared parent application context in a multi-war spring application

http://blog.springsource.org/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜