简体   繁体   中英

Absolute path of an EAR File

I am using Java , JBoss 5.1 , EJB and JasperReports library to generate reports.

We have a jrxml with a subreport and subreport expression is $P{SUBREPORT_DIR} + "ACC0401-RebatePayableAgingClosedLoans - SR1.jasper"

Where $P{SUBREPORT_DIR} is being passed from Java and file name ie "ACC0401-RebatePayableAgingClosedLoans - SR1.jasper" is known only to report.

Java is not aware about file name "ACC0401-RebatePayableAgingClosedLoans - SR1.jasper" , so I cant use getResourceAsStream() .

Now, I want to pass from Java code the following absolute path which is basically inside the EAR file.

/usr/local/jboss5.1.0.GA/server/default/deploy/OceanviewEAR.ear/OceanviewEJB.jar/com/oceanview/jasper/resource/config

My question is: In Java , how can I get the absolute path of EAR File so that i can pass that absolute path to JR report and then report will be able to locate the actual .jasper file.

This worked for me: use a URL instead of an absolute path.

InputStream url = getClass().getClassLoader().getResourceAsStream("/Report.jasper");
JasperPrint jasperPrint = JasperFillManager.fillReport(url, params, ds);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM