Reputation: 78
How to include a WAR file in another web project? If this is possible which Context do we need to use to hit services in WAR file and where do we need to place(location) the WAR file? I informed my lead that this is not possible as per my understanding, as server won't be able to resolve the request root to WAR which is placed in wrapper web project. Correct me if I'm wrong. Example - Consider we have two web projects A and B. I want to create WAR for project B and place it in project A. Thank you.
Upvotes: 1
Views: 5359
Reputation: 912
Like others have said, wars can't contain other wars.
However, if you are using maven then you can create a overlay. Which is really an easy way of exploding the contents of one war over another war. The resulting war will have one root context. If the goal is to share common content across multiple wars then this is a good route.
Upvotes: 1
Reputation: 719446
First, lets clear up a couple of possible misconceptions:
Putting a WAR file inside another WAR file doesn't make sense. Webapps don't contain other webapps. A WAR file inside another one simply won't work.
If one webapp simply needs to use another webapp, you don't need to include one project in the other. They can be (and arguably should be) separate projects.
But maybe you are actually talking about building an EAR file ... which is actually a deployable for a complete application container. That can sensibly contain multiple WAR files. But then we need to know what kind of project you are talking about. Is it an Eclipse or Netbeans project? It is a Maven module? Is it an Ant project?
Upvotes: 1
Reputation: 7899
Typically, war files don't contain war files. They can contain jar files; that's what the directory WEB-INF/lib
is for. If you want to bundle more than one web application together, you create an ear file and use an application server like Glassfish or JBoss. EAR files have another use with Enterprise JavaBeans too.
Upvotes: 1
Reputation: 15664
I don't think you can create a WAR inside a WAR.
But rather what you can do is create an interface for WAR B that is publicly exposed to the web.
And use that interface to communicate information from A to B and vice-versa.
Upvotes: 1