Classpath for Java archive within .ear file from a web application on JBoss 6.2
<h1>Background</h1>

<p>Running a J2EE application on JBoss. The Content Repository contains:</p>

<ul>
<li>WebApp.war</li>
<li>ReportService.ear</li>
<li>additional .jar files</li>
</ul>

<p>The <code>ReportService.ear</code> file contains:</p>

<pre><code>/ReportService-ejb.jar
/lib/*.jar
</code></pre>

<p>The <code>ReportService-ejb.jar</code> contains:</p>

<pre><code>/META-INF/reports/Report.jasper
/META-INF/reports/Subreport.jasper
</code></pre>

<h3>Environment</h3>

<ul>
<li>Java 1.7</li>
<li>NetBeans 8.0.2</li>
<li>JBoss 6.2.0 GA</li>
</ul>

<h1>Problem</h1>

<p>The following path must be on the CLASSPATH so that when the Web Application runs, the Report Service can find the root of the <code>META-INF</code> directory:</p>

<pre><code>ReportService.ear &gt;&gt; ReportService-ejb.jar &gt;&gt; /META-INF/.
</code></pre>

<p>That is, <code>Thread.currentThread().getContextClassLoader().getResource(filename)</code> must be able to read the file <code>/META-INF/reports/Report.jasper</code> when:</p>

<pre><code>filename = "/META-INF/reports/Report.jasper"
</code></pre>

<p>The problem is that when the reporting service tries to read the file, the following error appears, which is a custom error message that only happens if <code>getResource</code> fails to find the file:</p>

<pre><code>java.io.IOException: Missing resource path: '/META-INF/reports/Report.jasper'.
</code></pre>

<p>When running the Report Service unit tests against the deployment (over RMI), the reports run successfully. This could be because NetBeans is making the local copy of the report template files (i.e., the <code>/META-INF/reports/*.jasper</code> files) available.</p>

<h1>Additional Details</h1>

<p>Regarding the Web Application:</p>

<ul>
<li><code>MANIFEST.MF</code> is generated automatically by NetBeans using <code>project.properties</code> and currently does not contain a <code>Class-Path</code> entry.</li>
<li><code>jboss-app.xml</code> file contains only <code>&lt;jboss-app/&gt;</code>.</li>
<li><code>jboss-web.xml</code> file contains the context root, security domain, and other configuration items.</li>
<li><code>application.xml</code> does not exist.</li>
</ul>

<p>The <code>WebApp.war</code> file could also be bundled and deployed inside <code>WebApp.ear</code>.</p>

<h1>Question</h1>

<p>What file must be updated with a CLASSPATH so that the Web Application can use the Report Service to successfully find files in the <code>/META-INF/</code> directory of the <code>ReportService.jar</code>, which is nested within <code>ReportService.ear</code>?</p>

<p>Note: The build process (via build.xml and build-impl.xml) overwrites <code>MANIFEST.MF</code> each time <code>WebApp.war</code> is built.</p>

<h1>Ideas</h1>

<ul>
<li><p><strong>Update Build Scripts.</strong> Change build-impl.xml to update the manifest for WebApp.war to set a <code>Class-Path</code> entry that references ReportServices.jar. How will it find the .jar file if it is inside the ReportService.ear file?</p></li>
<li><p><strong>Update Web App EAR Manifest</strong>. Change <code>MANIFEST.MF</code> inside <code>WebApp.ear</code> to include a <code>Class-Path:</code> entry.</p></li>
</ul>

<h1>Resources</h1>

<ul>
<li><a href="https://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/ch01s04s02.html" rel="nofollow">JBoss Service Configuration Guide</a></li>
<li><a href="http://netbeans-org.1045718.n5.nabble.com/adding-to-the-netbeans-generated-manifest-s-Class-Path-td2871791.html" rel="nofollow">Adding Class-Path to NetBeans Generated Manifest</a></li>
<li><a href="http://www.onjava.com/pub/a/onjava/2001/06/26/ejb.html?page=2" rel="nofollow">EJB 2 and J2EE Packaging</a></li>
<li><a href="https://coderanch.com/t/315641/EJB-JEE/java/add-classpath-EAR-file" rel="nofollow">CodeRanch Thread</a></li>
<li><a href="http://www.developer.com/java/ejb/article.php/10931_3670496_2/Packaging-EJB-3-Applications.htm" rel="nofollow">Packaging EJB 3 Applications</a></li>
<li><a href="https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7" rel="nofollow">EAR Class Loading in AS7</a></li>
</ul>