使用pdfbox时出现致命错误JRE

时间:2017-11-08 22:43:22

标签: java pdfbox

我使用pdfBox(v2.0.8)生成PDF文件。当我在本地使用它似乎很好,我得到我的PDF格式。但是当我在一个码头工具中推送它时,我得到了这个致命的错误,这是hs_err_pid1.log

我不知道从哪里开始搜索修复程序,我不明白如何阅读此文件,因为它在本地工作,我无法重现该问题。

我怀疑我有一些提示,但我不知道如何处理这些信息:

(L.118)

j  org.myproject.services.impl.DntPdfGeneration.create(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;+198
j  org.myproject.services.impl.DntServiceImpl.pdfGeneration(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;+6
j  org.myproject.rest.impl.DntResourceImpl.getPdf(Ljava/lang/String;Ljava/lang/String;)Ljavax/ws/rs/core/Response;+6

编辑:

public class DntPdfGeneration {

private final JdbcStoreImpl jdbcStoreManager;

private static final Logger log = LoggerFactory.getLogger(DntPdfGeneration.class);

private static final String DNT_SQL_T_TAUX_DATA = "select * from some_table";

@Inject
public DntPdfGeneration(final JdbcStoreImpl jdbcStoreManager) {
    this.jdbcStoreManager = jdbcStoreManager;
}

public String create(String year, String t) {

    final String DNT_SQL_FIRST_LEVEL = "select * from table";

    final String DNT_SQL_SECOND_LEVEL = "select * from table";

    log.debug("Executing query");
    List<HashMap<String,Object>> DNT_SQL_1_DATA = null;

    List<HashMap<String,Object>> DNT_SQL_2_DATA = null;

    List<HashMap<String,Object>> DNT_T_TAUX_DATA = null;

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
    Date date = new Date();

    try {
        //Execute first sql statement and store data in DNT_SQL_1_DATA
        DNT_SQL_1_DATA = jdbcStoreManager.makeRawRequest(DNT_SQL_FIRST_LEVEL, "SCHEME");

        DNT_SQL_2_DATA = jdbcStoreManager.makeRawRequest(DNT_SQL_SECOND_LEVEL, "SCHEME");

        DNT_T_TAUX_DATA = jdbcStoreManager.makeRawRequest(DNT_SQL_T_TAUX_DATA,"SCHEME");

        String filePath = System.getenv("DNT_DBO_ENV")+"/"+dateFormat.format(date)+"-dnt.pdf";

        log.debug("Generating pdf file : {} ", filePath);

        PDDocument document = new PDDocument();

        DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
        symbols.setGroupingSeparator(' ');

        DecimalFormat formatter = new DecimalFormat("###,###.##", symbols);

        //Create new page
        PDPage singlePage = new PDPage(new PDRectangle(PDRectangle.A4.getHeight(), PDRectangle.A4.getWidth()));
        document.addPage(singlePage);
        PDPageContentStream contentStream = new PDPageContentStream(document, singlePage);

        int j = 1;

        Integer page = 1;

        int occurences = 0;

        //This boolean checks if 
        Boolean controlCot = false;

        Color littleGrey =  new Color(224,224,224);

        if (DNT_SQL_1_DATA.size() > 0) {

            for (int i=0;i<=DNT_SQL_1_DATA.size()-1;i++) {

                contentStream.beginText();
                contentStream.setFont(PDType1Font.HELVETICA, 8);
                contentStream.newLineAtOffset(760, 25);
                contentStream.showText("PAGE : "+page.toString());      
                contentStream.endText();

                //do more stuff and things ...

            }

            contentStream.close();
            document.save(filePath);
            if (document != null ) {
                document.close();
            }
         }
        return filePath;

    } catch (ClassNotFoundException | SQLException e) {
        log.error("SQL error : {}",e.getMessage());
        return null;
    } catch (IOException e) {
        log.error("IO Exeption : {}",e.getMessage());
        return null;
    }

0 个答案:

没有答案