title: GlassFish 3.1.2.2 war can't find jar inside ear
body: <p>I have built an ear with this structure (not all files shown here):</p>
  
  <pre><code>myapp.ear/
      myapp-ejb.jar
      myapp-web.war
      META-INF/
          application.xml
      lib
          myapp-common.jar
  </code></pre>
  
  <p>The problem is, when code in the war tries to reference classes in myapp-common.jar, it throws <code>java.lang.ClassNotFoundException</code>.</p>
  
  <p>Note the contents of <code>META-INF/application.xml</code>:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;application xmlns="http://java.sun.com/xml/ns/javaee"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                                   http://java.sun.com/xml/ns/javaee/application_6.xsd"
               version="6"&gt;
    &lt;display-name&gt;pncr-portal-ear&lt;/display-name&gt;
    &lt;module&gt;
      &lt;web&gt;
        &lt;web-uri&gt;myapp-web.war&lt;/web-uri&gt;
        &lt;context-root&gt;/&lt;/context-root&gt;
      &lt;/web&gt;
    &lt;/module&gt;
    &lt;module&gt;
      &lt;ejb&gt;myapp-ejb.jar&lt;/ejb&gt;
    &lt;/module&gt;
    &lt;library-directory&gt;/lib&lt;/library-directory&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>The library directory is defined here as being in the <code>/lib</code> directory relative to the root of the ear, which is exactly where it is, yet it is not loaded into the classpath despite the Java EE 5 (and presumably 6) spec saying that it should be loaded into the classpath.</p>