Solved

War file dependent on another war file

Posted on 2004-08-16
18
472 Views
Last Modified: 2011-09-20
Is there a possibility to include a war file in another war file, ie the manifest file?

cheers
0
Comment
Question by:oysteinpettersen
  • 8
  • 7
  • 3
18 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 11809698
That's really not desirable - war files are designed to be distinct and isolated. What exactly are you trying to do?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11809708
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
0
 

Author Comment

by:oysteinpettersen
ID: 11810864
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.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11810953
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.
0
 

Author Comment

by:oysteinpettersen
ID: 11811049
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
0
 
LVL 35

Expert Comment

by:girionis
ID: 11811136
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.
       
0
 

Author Comment

by:oysteinpettersen
ID: 11817869
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
0
 
LVL 35

Expert Comment

by:girionis
ID: 11817919
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.
0
 

Author Comment

by:oysteinpettersen
ID: 11818243
I take it this all needs to be packed in a ear file?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 35

Expert Comment

by:girionis
ID: 11818301
No. A zip file would be enough. Then after you unzip the zip file you deploy each war file separately.
0
 

Author Comment

by:oysteinpettersen
ID: 11818849
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.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11818894
> 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.
0
 

Author Comment

by:oysteinpettersen
ID: 11819326
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
0
 
LVL 35

Expert Comment

by:girionis
ID: 11819401
If you find a way please let us know also as I am curious if/how this can be done.
0
 

Author Comment

by:oysteinpettersen
ID: 11820363
No problem, will do.
0
 

Author Comment

by:oysteinpettersen
ID: 11905691
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.  
0
 
LVL 35

Expert Comment

by:girionis
ID: 11907111
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:

http://www.experts-exchange.com/Community_Support/
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11911509
:-)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now