有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在ApacheTomcat上部署GWT应用程序

在服务器端,我有一个用于将SVG文件转换为PDF的类

public class PdfHandler {
    private File savedFile;
    private File svgTempFile;

    public PdfHandler(String fileName) {
        this.savedFile = new File(File.separator + "documents" + File.separator + fileName);
    }

    public void convertToPdf(String inputFileName) {
        this.svgTempFile = new File(inputFileName);
        System.out.println(inputFileName);
        if (this.svgTempFile.exists()){
            System.out.println("Svg File exists");
        }
        else {
            System.out.println("Svg File not exists");
        }

        try {
            Transcoder transcoder = new PDFTranscoder();
            System.out.println("Transcoder created");
            FileInputStream fis = new FileInputStream(this.svgTempFile);
            System.out.println("Input stream created");
            FileOutputStream fos = new FileOutputStream(this.savedFile);
            System.out.println("Output stream created");
            TranscoderInput transcoderInput = new TranscoderInput(fis);
            System.out.println("Transcoder input created");
            TranscoderOutput transcoderOutput = new TranscoderOutput(fos);
            System.out.println("Transcoder output created");
            transcoder.transcode(transcoderInput, transcoderOutput);
            System.out.println("Conversion finished");

            fis.close();
            fos.close();
        } catch (Exception ex) {
            ex.printStackTrace();
            System.out.println("Exception");
        } finally {
            this.svgTempFile.delete();
            System.out.println("File deleted");
        }
            System.out.println("End of method");
    }
}

我有一个RPC调用的方法

public String generatePdf(PayDoc filledDoc) {
    //String svgFileName = this.generateSvg(filledDoc);
    //String pdfFileName = this.generateFileName("pdf");
    PdfHandler pdfHandler = new PdfHandler("myPdf.pdf");
    pdfHandler.convertToPdf(File.separator + "documents" + File.separator + "mySvg.svg");
        return null;//pdfFileName;
}

在eclipse中,所有这些都可以正常工作,但在Tomcat上不行。当我在Tomcat上调用它时,RPC失败 这是Tomcat控制台输出:

\documents\mySvg.svg
Svg File exists
Transcoder created
Input stream created
Output stream created
Transcoder input created
Transcoder output created
File deleted

在“文档”文件夹中,我有“mySvg.svg”(仍然没有删除)和“myPdf.pdf”(它是空的)


共 (1) 个答案

  1. # 1 楼答案

    看起来您没有在部署的应用程序中包含所需的库

    ElementTraversalxml-apis-X.XX.X.jar的一部分,必须与应用程序捆绑在一起

    由于有大量的构建工具,我不知道您使用的是哪一种,所以我不能建议更改