Dave Jarvis
Dave Jarvis

Reputation: 31161

Classpath for Java archive within .ear file from a web application on JBoss 6.2

Background

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

Environment

Problem

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.

Additional Details

Regarding the Web Application:

The WebApp.war file could also be bundled and deployed inside WebApp.ear.

Question

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.

Ideas

Resources

Upvotes: 1

Views: 1393

Answers (1)

Dave Jarvis
Dave Jarvis

Reputation: 31161

Change:

Thread.currentThread().getContextClassLoader().getResource(filename)

to:

getClass().getResource(filename)

Upvotes: 1

Related Questions