How to add a custom JBoss archive in an EAR ?

JBoss custom archives (like SAR or HAR) are not recognized by the application.xml configuration file, so in order to deploy them in an EAR you have to declare them in jboss-app.xml. This file is located in the META-INF folder of your EAR.

For example, if you want to include an Hibernate Archive (HAR), you have to provide the following jboss-appl.xml configuration:

<jboss-app>
   <module>
      <har>sample.har</har>
   </module>
</jboss-app>

If you want to provide a .sar archive then you would need:

<jboss-app>
  <module>
    <service>sample.sar</service>
  </module>
</jboss-app>

You can also add a web application module configuration, which will override the default EAR configuration:

<module>
    <web>
       <web-uri>myapp.war</web-uri>
       <context-root>/myapp</context-root>
    </web>
</module>