Link to home
Start Free TrialLog in
Avatar of oysteinpettersen
oysteinpettersen

asked on

War file dependent on another war file

Is there a possibility to include a war file in another war file, ie the manifest file?

cheers
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you just need libraries, then the libraries from war A should be packaged into war B. You can't include a reference in war B to war A
Avatar of oysteinpettersen
oysteinpettersen

ASKER

I have a set of JSP that are common to more than one war application. Was hoping there was a better way to package this, than duplicate these common jsp's in all of the war applications.
Why don't you have a common folder that is accessible from all the web apps and you do not have to duplicate all the files over all the web applications? You can do this by packaging everything in a zip file and then, after unzipping, deploy the war file. The common JSP pages will already be where they should eb and the deployment of the war file should not have any affect on them.
How excatly would this be done with precompilation of the jsp. Please elaborate on the location of the common folder and why you would need to use a zip file. I am using JBoss 3.2.3.

Cheers
You do not need to precompile the JSP files, the servlet engine will take care of it, you just need to put them in a folder that is accessible and visible by all other web applications.

Put everything in a zip file, in a structure like

myfolder--
       common---
            A.jsp
            B.jsp
            C.jsp
       warfile1.war
       warfile2.war

and then deploy the war files. Make sure they can see the myfolder/common directory.
       
How do you make sure they can see the myfolder/common directory? Is this the virtual mapping in the web.xml file? Still unsure why we would need to pack everything in a zip file.....

Cheers
You need to pack everything in a zip file because you have to force a specific directory structure.

The myfolder/common could as well be another web application. Then you just do an HTTP request to it by using relative paths (e.g. <a href="../myfolder/common/A.jsp">A.jsp</a>) and so on. It all depends on how you read/execute these JSP file.
I take it this all needs to be packed in a ear file?
No. A zip file would be enough. Then after you unzip the zip file you deploy each war file separately.
The problem with this solution is that as we are using struts we want to specify the jsp forward pages in the struts-config.xml file. This can only refrence jsp inside that war. If we use the struts redirect option we lose all request data. Might have to revert to the old solution of copy in all common jsp at war build time.
> The problem with this solution is that as we are using struts we want to specify the jsp forward
> pages in the struts-config.xml file. This can only refrence jsp inside that war.

I thought you could reference pages anywhere in the web application folders. Anyway, if you think it cannot be done then the only solution I guess is to copy everything in the war file.
Have seen some attempts to stick this common files in a common folder in the ear and specifiy this is the war manifest files. There was no indication that this had worked. Will keep looking, but for now I have to copy all the common jsp files to all the war files. The static js, html and pictures can be in a common web application.

I still think there should be a more elegant way of doing this....... will keep looking.

Cheers
If you find a way please let us know also as I am curious if/how this can be done.
No problem, will do.
Ok my findings are.....

In order to have a common place for jsp files shared among diffrent war, one solution is to Precompile the jsp using ant and the jspc tag. Pack the compiled jsp files in a jar, and place the generated web xml mappings in a file of some kind. The jar can then be placed in the ear file accessable for all war files. Now when you pack your wars you need to include the generated web xml mappings from the common section in each web.xml for each war.

This is the best idea that I could come up with, but becase you have to include all the mappings in the web xml for each war you would need to compile all the war if you introduced a new common jsp or changed the name of a current one.

I my case we sat down and looked at all the seprate wars and concluded that one of our wars are isolated and complete. The application that they together create needs all of them to function properly. Therefore we are going to merge them all into one "isolated and complete" war. This will for the time being eliminate our need to share common jsp files. Nevertheless we know that the next project in the pipe line will / can use many of the jsp from the current project so we will be faced with this issue again (if they run on the same box).

It looks to me that this is something that was not connsidered a good idea when I came to wars. Looks like the way to do it is to pack each of them with all
the files they need even if it creates duplication files in runtime stage.

So that is it really......... thanks for endulging in this discussion.  
Nice :)

Please if you feel you have been helped accept an answer/split points, otherwise ask a question to community support for zero points to PAQ thsi quesiton and refund the points back to you:

https://www.experts-exchange.com/Community_Support/
:-)