tags:

views:

435

answers:

6
+3  Q: 

jEE war files

is it possible to include/embed one JEE application(war file) inside another?

i have an application which is a portal application and i want to allow other users add there applications to it. In order to do this i need some way to be able access there applications in mine.

Is this possibe?

+4  A: 

You cannot put WARs inside of other WARs. You need an EAR file to contain WARs, EJBs, etc. One way to implement inter-WAR communication is to package that logic directly in the EAR. It all depends on what you're trying to do.

Chris Noe
To elaborate, an EAR is a container for other JEE deployable packages, such as WARs, EJB JARs, and so on.
skaffman
A: 

ok so can i put both war files into the same EAR and have war A reference war B?

combi001
(This "answer" should have been entered as a comment to the answer it was addressing.)
Chris Noe
+1  A: 

Maybe you need a plugin system or portlet, so your user will not develop a war application but include their portlet inside your application (war). There's a standard : JSR 168 and several implementations : http://developers.sun.com/portalserver/reference/techart/jsr168/

Matthieu
A: 

how do you package the inter war communictaion in the EAR? i want to be able embed the contents of war B inside a portlet in application A

combi001
I suggest you follow Matthieu's advice, since it sounds like you will be needing strong portlet support. (Address further questions as a comment to his answer.)
Chris Noe
+1  A: 

As others have pointed out, embedding WARs inside WARs is not an option. However, I may have a workaround for you.

Most Web containers I'm familiar with have a "test deployment / auto deploy" mode / capability, where they will automatically deploy an application if the WAR is copied into the right directory.

Your portal application could certainly allow uploading WARs, and it could store the uploaded bytes in a given directory under a given file name. Your Web container could do the rest. You could then link to the new application from your portal, or whatever. All this is relatively easy to do.

However, be advised that this is a horrible idea if there is any security concern whatsoever. You are essentially allowing your users to execute arbitrary code on your server. Unless you completely trust all potential users to be both non-malicious and perfectly competent (think infinite loops), you are asking for a lot of trouble here.

Carl Smotricz
I'm queasy about this one. (At least you do point out your security concerns.)
Chris Noe
+2  A: 

the way to do inter .WAR communication is by the method http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getContext(java.lang.String)

ServletContext.getContext(URIOfOtherWAR_resource)

I've used this succesfully for doing what you're talking about.

anjanb