JBoss SAR vs EAR/WAR packaging

15,265

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!

Share:
15,265
nemo
Author by

nemo

Updated on June 17, 2022

Comments

  • nemo
    nemo almost 2 years

    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.

  • Max Nanasy
    Max Nanasy about 10 years
    SARs do not seem to be JBoss-specific; for instance, WebSphere seems to support them (see documentation).
  • Max Nanasy
    Max Nanasy about 10 years
    Upon closer inspection, WebSphere uses SAR to mean "Session Initiation Protocol (SIP) archive", which is probably different from "service archive".
  • CoolBeans
    CoolBeans about 10 years
    Perhaps so. I have not that familiar with Websphere. Thank you for the comment, it's a good info.