Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JBoss SAR vs EAR/WAR packaging

When would I choose to deploy as a JBoss SAR instead of an EAR?

This is more of a general question and I'm looking for guidelines that explain the pros and cons of each deployment model and which one is applicable when.

like image 751
nemo Avatar asked Apr 27 '12 18:04

nemo


People also ask

What is Java SAR file?

SAR file is created with the . sar extenstion same like how other archive files (JAR, WAR, EAR) created. But the purpose of the SAR file is differenet from the other archive files. It is used for deploying a service component in the application server without dependent on other components.


1 Answers

You will build a SAR (service archive) when you want to expand the capabilities of the server. For example, JBoss uses SARs for EJB deployer or messaging. You can create one for your own service monitoring (ie. watch some metrics for one of your custom services). As far as I know SARs are unique to JBoss only.

From my personal experience, I once created a SAR to keep track of a web service. I mainly used the service component to keep track of the length of a list of things that the web service component created. This was one way I could poke in the jmx-console and find out some metrics about the incoming requests to the web service.

SARs are based on JMX specs so it's not difficult to create them. You basically create a standard MBean interface and implement that interface. You will also want to make sure you that you have a jboss-service.xml file in the META-INF directory.

On the other hand WARs and EARs are for standard application packaging where you expect the container to manage and process requests for the application. You don't expect the application to be running as an anonymous service component like you do in case of a SAR packaged application.

Hope this helps!

like image 112
CoolBeans Avatar answered Oct 03 '22 03:10

CoolBeans