Reputation: 31161
Running a J2EE application on JBoss. The Content Repository contains:
The ReportService.ear
file contains:
/ReportService-ejb.jar
/lib/*.jar
The ReportService-ejb.jar
contains:
/META-INF/reports/Report.jasper
/META-INF/reports/Subreport.jasper
The following path must be on the CLASSPATH so that when the Web Application runs, the Report Service can find the root of the META-INF
directory:
ReportService.ear >> ReportService-ejb.jar >> /META-INF/.
That is, Thread.currentThread().getContextClassLoader().getResource(filename)
must be able to read the file /META-INF/reports/Report.jasper
when:
filename = "/META-INF/reports/Report.jasper"
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 getResource
fails to find the file:
java.io.IOException: Missing resource path: '/META-INF/reports/Report.jasper'.
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 /META-INF/reports/*.jasper
files) available.
Regarding the Web Application:
MANIFEST.MF
is generated automatically by NetBeans using project.properties
and currently does not contain a Class-Path
entry.jboss-app.xml
file contains only <jboss-app/>
.jboss-web.xml
file contains the context root, security domain, and other configuration items.application.xml
does not exist.The WebApp.war
file could also be bundled and deployed inside WebApp.ear
.
What file must be updated with a CLASSPATH so that the Web Application can use the Report Service to successfully find files in the /META-INF/
directory of the ReportService.jar
, which is nested within ReportService.ear
?
Note: The build process (via build.xml and build-impl.xml) overwrites MANIFEST.MF
each time WebApp.war
is built.
Update Build Scripts. Change build-impl.xml to update the manifest for WebApp.war to set a Class-Path
entry that references ReportServices.jar. How will it find the .jar file if it is inside the ReportService.ear file?
Update Web App EAR Manifest. Change MANIFEST.MF
inside WebApp.ear
to include a Class-Path:
entry.
Upvotes: 1
Views: 1393
Reputation: 31161
Change:
Thread.currentThread().getContextClassLoader().getResource(filename)
to:
getClass().getResource(filename)
Upvotes: 1