How do I change the default lib directory in an ear file?

Supposing you have an Enterprise application which has been packaged in an ear and its libraries are placed in another folder like Weblogic’s APP-INF/lib. How can I deploy this application to JBoss ? Since Java EE 5 you can include the library-directory parameter in your META-INF/application.xml file:

<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd">
   <module>
      <ejb>hello-ejb.jar</ejb>
   </module>
   <module>
      <web>
         <web-uri>myapp.war</web-uri>
         <context-root>myapp</context-root>
      </web>
   </module>
   <library-directory>APP-INF/lib</library-directory>
</application>

As an alternative, you can include the same parameter in your jboss-app.xml. Here’s an example:

<application>
  <display-name>My Application</display-name>
  <module>
    <web>
      <web-uri>myapp.war</web-uri>
      <context-root>/myapp</context-root>
    </web>
  </module>

  <module>
    <ejb>myapp.jar</ejb>
  </module>
  
  <library-directory>APP-INF/lib</library-directory>

</application>