Я использую BIRT без проблем на Eclipses, но моя новая компания использует IntelliJ IDEA.
Использование проекта с Gradle
compile files('src/main/resources/lib/flute-1.3.jar')
compile(group: 'org.eclipse.birt.runtime', name: 'org.eclipse.birt.runtime', version: '4.4.2') { exclude(group: 'org.milyn', module: 'flute') }
У меня нет проблем при запуске локальным методом main. Но после компиляции проекта через
shadowJar {
classifier = null
version = version
manifest {
attributes 'Main-Class': 'io.vertx.core.Starter'
attributes 'Main-Verticle': 'other.app.App'
}
mergeServiceFiles {
include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
}
}
Я получил ноль на
IReportEngineFactory factory = (IReportEngineFactory) Platform .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
Пытаясь обойти эту проблему в течение недели, я все еще не могу найти решение. У кого-нибудь есть предложения? Тисм для чтения.
Мой код на нем:
@Override
public void generateUserInformationPdf(JsonObject payload) {
try {
LOGGER.info("Starting render User Information");
/* begin get parameters */
CommonRequest request = gson.fromJson(payload, CommonRequest.class);
UserPdfPrint userInformation = gson.fromJson(request.getData(), UserPdfPrint.class);
String p_username = userInformation.getUsername();
String p_customername = userInformation.getCustomerName();
String p_dob = userInformation.getDob();
String p_license = userInformation.getLicense();
String p_licensedate = userInformation.getLicenseDate();
String p_licenseplace = userInformation.getLicensePlace();
String p_sex = userInformation.getSex();
String p_customerphone = userInformation.getCustomerPhone();
String p_email = userInformation.getEmail();
int p_licensetype = userInformation.getLicenseType();
/* end get parameters section */
/* load report design */
String reportName = config.getReportUserInformation();
IReportEngine engine = null;
IReportRunnable design = null;
URL url = null;
url = new URL(config.getReportFontConfig());
engineConfig = new EngineConfig();
engineConfig.setEngineHome("ReportEngine");
engineConfig.setLogConfig(null, Level.FINE);
engineConfig.setFontConfig(url);
Platform.startup(engineConfig);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(engineConfig);
design = engine
.openReportDesign(config.getReportTemplatePath()
+ "/" + reportName); // report
/* end load report design */
/* begin render report */
IRunAndRenderTask task = null;
PDFRenderOption renderContext = null;
HashMap contextMap = null;
task = engine.createRunAndRenderTask(design);
renderContext = new PDFRenderOption();
contextMap = new HashMap();
contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
renderContext);
contextMap.put("OdaJDBCDriverPassInConnection", config.getDbConnection());
task.setAppContext(contextMap);
task.setParameterValue("p_username", p_username);
task.setParameterValue("p_customername", p_customername);
task.setParameterValue("p_dob", p_dob);
task.setParameterValue("p_license", p_license);
task.setParameterValue("p_licensedate", p_licensedate);
task.setParameterValue("p_licenseplace", p_licenseplace);
task.setParameterValue("p_sex", p_sex);
task.setParameterValue("p_licensetype", String.valueOf(p_licensetype));
task.setParameterValue("p_email", p_email);
task.setParameterValue("p_customerphone", p_customerphone);
task.validateParameters();
String random = Generator.generateRandomNumber();
String today = DateTimes.getCurrentDate().toString();
String parsedToDate = DateTimes.parseDate(today, "EE MMM dd HH:mm:ss z yyyy").toString();
String toDateString = DateTimes.parseDate(parsedToDate, "dd-MM-yyyy-hh-mm-ss").toString();
String reportNameInFolder = "UserInformation" + toDateString
+ random;
String outPutFile = config.getReportOutputPath() + reportNameInFolder + ".pdf";
PDFRenderOption options = null;
options = new PDFRenderOption();
options.setOutputFormat("pdf");
options.setOutputFileName(outPutFile);
task.setRenderOption(options);
task.run();
System.out.println("All went well. Closing program!");
/* end render report */
engine.destroy();
task.close();
options.closeOutputStreamOnExit(true);
mqAdapter.pushToMQ(Transformers.toVertxJsonObject(new EnhancedSuccessResponse()
.setHeader(request.getHeader())
.setCodes(CodeResponse.SuccessCode.PRINT_PDF_REGISTER_SUCCESS.getCode())
.setData(gson.toJsonTree(new PdfReportResponse().setPdfLink(config.getReportOutputLink() + reportNameInFolder + ".pdf")))).encode(), QueueKeys.OtherQueue.ADMIN_GENERATE_USER_INFORMATION_PDF.getValue());
} catch (MalformedURLException e) {
LOGGER.error("Failed to get Font Config URL. {}", e.toString());
} catch (BirtException e1) {
LOGGER.error("Failed to start config. {}", e1.toString());
// e1.printStackTrace();
} catch (
Exception e) {
LOGGER.error("Failed to get design template. {}", e.toString());
System.err
.println("An error occured while running the report!");
LOGGER.error("An error occured while running the report! {}", e.toString());
// e.printStackTrace();
}
}