起動時にプログラムでレポートを初期化するときに問題が発生しました。少し前までは、正しく動作していました。しかし、JDK 1.7 update 17 を JDK 1.7 update 21 にアンインストールし、Netbeans を新規インストールすると、例外が存在します:(
これはエラーメッセージです:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at sun.font.ExtendedTextSourceLabel.createCharinfo(ExtendedTextSourceLabel.java:609)
at sun.font.ExtendedTextSourceLabel.getCharinfo(ExtendedTextSourceLabel.java:509)
at sun.font.ExtendedTextSourceLabel.getLineBreakIndex(ExtendedTextSourceLabel.java:455)
at java.awt.font.TextMeasurer.calcLineBreak(TextMeasurer.java:325)
at java.awt.font.TextMeasurer.getLineBreakIndex(TextMeasurer.java:561)
at java.awt.font.LineBreakMeasurer.nextOffset(LineBreakMeasurer.java:358)
at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.measureExactLineBreakIndex(SimpleTextLineWrapper.java:561)
at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.measureExactLine(SimpleTextLineWrapper.java:535)
at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.nextLine(SimpleTextLineWrapper.java:517)
at net.sf.jasperreports.engine.fill.TextMeasurer.renderNextLine(TextMeasurer.java:649)
at net.sf.jasperreports.engine.fill.TextMeasurer.renderParagraph(TextMeasurer.java:454)
at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:395)
at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:541)
at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:641)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:331)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:379)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:353)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:458)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:421)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:282)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:822)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:61)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745)
at com.ikbiz.gastroscope.controller.ReportController.initReport(ReportController.java:180)
at com.ikbiz.gastroscope.controller.ReportController.<init>(ReportController.java:111)
at com.ikbiz.gastroscope.view.PanelScope.<init>(PanelScope.java:32)
at com.ikbiz.gastroscope.view.PanelEntry.initComponents(PanelEntry.java:199)
at com.ikbiz.gastroscope.view.PanelEntry.<init>(PanelEntry.java:86)
at com.ikbiz.gastroscope.view.Application.initComponents(Application.java:203)
at com.ikbiz.gastroscope.view.Application.<init>(Application.java:35)
at com.ikbiz.gastroscope.view.Application.getInstance(Application.java:43)
at com.ikbiz.gastroscope.view.Application.main(Application.java:79)
Java Result: 1
そして、これはレポートを初期化するための私のコードです。
public void initReport() {
try {
param.put("noMr", "0000");
param.put("visitCode", "V-199208300000");
param.put("templateLoco", iReportDir);
param.put("tools", "Tools");
param.put("medicine", "Medicine");
param.put("result", "Data hasil disini");
param.put("conclusion", "Data kesimpulan disini");
param.put("suggestion", "Suggestion");
param.put("SUBREPORT_DIR",iReportDir);
String imageLoco = iReportDir +"image-sample.jpg";
for (int i = 0; i < 20; i++) {
FileInputStream image = new FileInputStream(imageLoco);
param.put("imgResult"+(i+1), image);
}
param.put("emptyImg", iReportDir+"logo.jpg");
setTemplate("data/reports/templates/template_1.jasper");
jasperPrint = JasperFillManager.fillReport(getTemplate(), param, DatabaseUtility.getConnection());
} catch (JRException ex) {
System.out.println(ex.getMessage());
} catch (IOException ioe) {
System.out.println(ioe.getMessage());
}
}
しかし、私が構築するとき。ジャー、エラーが消えます。
助けてください、前にありがとう:)