Got it,
This might also help others with the same question, so thanks to Monroe and GregJohnson and a few additions i found out. Sorry Images could not be attached,
Question
When would someone want to package 2 war files together
Answer
Your application might be made up of 2 completely separate web applications e.g. a website utilising a open source Forum package e.g. Jforum. In this case the 2 web applications are difficult to combine into one, see Bottom for Pros and cons
Java EE projects are either EAR or WAR deployments that use Java EE technology. If you have a WAR with JSPs and
JDBC access of a relational database, that's a Java EE project. The original intent was that EAR files were "enterprise", and that meant EJBs. An EAR file an contain EJBs, WARs, JARs, the whole enchilada.
Thinking in terms of services are a little different. I think deployment deserves careful consideration, because components that are packaged together must be brought down and up together if any maintenance has to be done.
So think carefully about how you package your services. It's not an all or none blanket answer, IMO.
You should look at what your services are doing and how they might be used together to decide how they should be packaged and deployed.
Also I think what you decide to put in each EAR is governed by organizational and technical issues.
I think most important technical role of an EAR is a classloader root in a runtime environment. This normally means you can deploy different versions of libraries and your own classes in different EAR's. This means you should keep your container root classpath fairly empty (or as supplied by the container vendor), because it may allow one phsyical container to service multiple applications using possibly conflicting libraries. This is great news if you're developing a number of different applications using a common code-base. You can have a number of projects deploying to the same farm of servers without messing up for eachother.
You will normally never deploy a smaller
unit of software than the EAR. Each EAR can be more or less fully self-contained. I would normally let the content of these refelect what the owning organization thinks of as applications or subsystems. You can usually package the same components in multiple EAR's.
Single war or Two separate wars - which is the best solution for Integrating Jforum
Single War file i.e. Same context with 2 apps:
Pros
Everything is in the same class loader so stuff like session variables, jforum repository cache objects, and the like are available to both apps. This can make tight integration much easier.
you should be just be able to get everything you need directly from the session.
i.e. in authenticateUser method, just do something like:
SessionContext sctx =ctx.getSessionContext();
User u = (User)sctx.getAttribute("USER"); // or what ever acegi uses for here at login
if (u != null){
// user is loged in with valid session.
// note: if u still want the email to persist..I think u still need to place this into cookie.
// else u need to hack the jforum code to get in the right place.
return user.userName();
}
else
{
// not logged, return null;
}
Cons
Dependency conflicts, harder to upgrade to a new version because everything needs to be checked again.
Potential security issues (low probablity... but).. You've got "other peoples" code running with your code.
Scalablity... - You have to set up a completely different jforum instance for each application instance.. may not be an issue except if you need to support many clients or communities.
Separate contexts (2 wars)
Pros:
Better security
Easier to update jForum to new versions
No dependencies problems
Cons:
More complex to integrate apps, e.g. SSO and the like.
i.e. If you decide to keep the JForum logic its own war, your only option is to use a cookie, or JAAS...The advantage of the cookie solution is, it will work cross Servers, in case we need load balancing
Look and feel / Navigational issues. E.g., do you modify jForum to look like your main app or use iframes to provide the "wrapping".
How to package 2 war files in one ear File Using Netbeans
Simple just create an Enterprise Application in Netbeans and call it e.g. testenterpriseapp
You get 3 projects in the Projects Window, a war,
EJB and the Ear project as below
So how do we add the other war project ??? Simple, just create a New web application along the way, the wizard will give the Server Setting Dialogue Box
Choose Add to Enterprise application and choose the Ear file e.g testenterpriseapp in the case, and simply run/Build!!!
[originally posted on jforum.net by ngonidan2]