Java Ghost4J-异常\访问\冲突(JVM正在崩溃)

Java Ghost4J-异常\访问\冲突(JVM正在崩溃),java,ghost4j,Java,Ghost4j,我正在尝试替换公司使用的PDF转换器,但Ghost4J出现了这个问题。注意我的代码与他们提供的示例非常相似 我正在使用JavaSE1.6(jrockit-jre1.6.0!u33-R28.2.4)和Ghostscript9.10实现64位Win 我的代码是: public void convertPostScriptToPDF() { File file= new File (this.getClass().getResource( "/resources/employer_re

我正在尝试替换公司使用的PDF转换器,但Ghost4J出现了这个问题。注意我的代码与他们提供的示例非常相似

我正在使用JavaSE1.6(jrockit-jre1.6.0!u33-R28.2.4)和Ghostscript9.10实现64位Win

我的代码是:

public void convertPostScriptToPDF() {
        File file= new File (this.getClass().getResource( "/resources/employer_report_last_page.ps").getFile());
        FileOutputStream fos = null;
        try{

            //load PostScript document
            PSDocument document = new PSDocument();
            document.load(file);        

            fos = new FileOutputStream(new File("rendition.pdf"));    
            //create converter
            PDFConverter converter = new PDFConverter();

            //set options
            converter.setPDFSettings(PDFConverter.OPTION_PDFSETTINGS_PREPRESS);

            //convert
            converter.convert(document, fos);

        } catch (Exception e) {
            System.out.println("ERROR: " + e.getMessage());
        } finally{
            IOUtils.closeQuietly(fos);
        }
    }
JVM崩溃发生在“converter.convert(document,fos);”上,在转储文件上显示以下消息:

Error Message: Illegal memory access. [54]
Exception Rec: EXCEPTION_ACCESS_VIOLATION (00000000c0000005) at 0x0000000067ECE347 - memory at 0xFFFFFFFFFFFFFFFF could not be read.
Minidump     : Wrote mdmp. Size is 650MB
SafeDllMode  : -1
Version      : Oracle JRockit(R) R28.2.4-14-151097-1.6.0_33-20120618-1634-windows-x86_64
CPU          : Intel  SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 Intel64**strong text**
Number CPUs  : 4
Tot Phys Mem : 4110749696 (3920 MB)
OS version   : Microsoft Windows 7 version 6.1 Service Pack 1 (Build 7601) (64-bit)
Thread System: Windows Threads
Java locking : Lazy unlocking enabled (class banning) (transfer banning)
State        : JVM is running
Command Line : -Xms=512m -Xmx=512m -Dfile.encoding=Cp1252 -Dsun.java.command=org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 57292 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -test au.edu.nsw.det.reportgenerator.business.ReportManagerTest:convertPostScriptToPDF -Dsun.java.launcher=SUN_STANDARD org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 57292 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -test au.edu.nsw.det.reportgenerator.business.ReportManagerTest:convertPostScriptToPDF
Repository   : 
java.home    : C:\Program Files\Java\jrockit-jre1.6.0_33-R28.2.4
j.class.path : C:\EmployerReportGenerator\bin;C:\EmployerReportGenerator\lib\emp-model.jar;C:\EmployerReportGenerator\lib\ghost4j-0.5.0.jar;C:\EmployerReportGenerator\lib\commons-io-1.3.1.jar;C:\EmployerReportGenerator\lib\jna-platform-4.0.0.jar;C:\EmployerReportGenerator\lib\log4j-1.2.15.jar;C:\EmployerReportGenerator\lib\xmlgraphics-commons-1.4.jar;C:\EmployerReportGenerator\lib\commons-beanutils-1.8.3.jar;C:\EmployerReportGenerator\lib\commons-logging-1.1.1.jar;C:\EmployerReportGenerator\lib\itext-2.1.7.jar;C:\EmployerReportGenerator\lib\jna-3.3.0.jar;C:\projects\det\lib\jasperreports-1.2.8.jar;C:\projects\det\release\PDFGeneratorService-client-1.0.jar;C:\TBO\DependentJars\ojdbc14.jar;C:\oracle\oc4j10.1.3.2\j2ee\home\applib\rdbthin.jar;C:\projects\det\release\xmlCommon-1_0.jar;C:\projects\det\release\jet-3_0.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\ejb-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\jca-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\jms-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\jsp-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\jta-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\servlet-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\sql-api.jar;C:\eclipse\plugins\org.junit_4.10.0.v4_10_0_v20120426-0900\junit.jar;C:\eclipse\plugins\org.hamcrest.core_1.1.0.v20090501071000.jar;C:\projects\det\lib\commons-logging-1.1.jar;/C:/eclipse/configuration/org.eclipse.osgi/bundles/346/1/.cp/;/C:/eclipse/configuration/org.eclipse.osgi/bundles/979/1/.cp/
j.lib.path   : C:\Program Files\Java\jrockit-jre1.6.0_33-R28.2.4\bin;C:\Windows\system32;C:\Windows;C:\app\tfirmino\product\11.2.0\client_1;C:\app\tfirmino\product\11.2.0\client_1\bin;C:\oracle\product\10.2.0\client_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Common Files\GTK\2.0\bin;C:\Program Files (x86)\cvsnt;C:\Program Files\Internet Explorer;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\Program Files\SlikSvn\bin;C:\Program Files (x86)\Sybase\Shared\PowerBuilder\;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\Users\thais.firmino\Application Data\SSH\UserKeys;C:\Python27;C:\Program Files\apache-maven-3.0.5\bin;C:\Program Files\Java\jdk1.7.0_17\bin;;.
JAVA_HOME    : C:\Program Files\Java\jdk1.7.0_17\
_JAVA_OPTIONS: <not set>
PATH         : C:\app\tfirmino\product\11.2.0\client_1;C:\app\tfirmino\product\11.2.0\client_1\bin;C:\oracle\product\10.2.0\client_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Common Files\GTK\2.0\bin;C:\Program Files (x86)\cvsnt;C:\Program Files\Internet Explorer;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\Program Files\SlikSvn\bin;C:\Program Files (x86)\Sybase\Shared\PowerBuilder\;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;C:\Users\thais.firmino\Application Data\SSH\UserKeys;C:\Python27;C:\Program Files\apache-maven-3.0.5\bin;C:\Program Files\Java\jdk1.7.0_17\bin;
StackOverFlow: 0 StackOverFlowErrors have occured
OutOfMemory  : 0 OutOfMemoryErrors have occured
C Heap       : Good; no memory allocations have failed
GC Strategy  : Mode: throughput, with strategy: genparpar (basic strategy: genparpar)
GC Status    : OC is not running. Last finished OC was OC#0.
             : YC is not running. Last finished YC was YC#0.        
错误消息:非法内存访问。[54]
异常记录:0x0000000067ECE347处的异常访问冲突(00000000 C0000005)-无法读取0xFFFFFFFFFFFF处的内存。
Minidump:编写mdmp。大小为650MB
安全模式:-1
版本:Oracle JRockit(R)R28.2.4-14-151097-1.6.0_33-20120618-1634-windows-x86_64
CPU:Intel SSE2 SSE3 SSE3 SSE4.1 SSE4.2 Intel64**强文本**
CPU数量:4
总物理内存:4110749696(3920 MB)
操作系统版本:Microsoft Windows 7版本6.1 Service Pack 1(版本7601)(64位)
线程系统:Windows线程
Java锁定:启用延迟解锁(类禁止)(传输禁止)
状态:JVM正在运行
命令行:-Xms=512m-Xmx=512m-Dfile.encoding=Cp1252-Dsun.java.Command=org.eclipse.jdt.internal.junit.runner.RemoteTestRunner-version 3-port 57292-testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader-loaderpluginname org.eclipse.jdt.junit4.runtime-testau.edu.nsw.det.reportgenerator.business.ReportManagerTest:convertPostScriptToPDF-Dsun.java.launcher=SUN_标准org.eclipse.jdt.internal.junit.runner.RemoteTestRunner-version 3-port 57292-testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader-loaderpluginname org.eclipse.jdt.junit4.runtime-testau.edu.nsw.det.reportgenerator.business.ReportManagerTest:convertPostScriptToPDF
存储库:
java.home:C:\Program Files\java\jrockit-jre1.6.0\u 33-R28.2.4
j、 class.path:C:\EmployerReportGenerator\bin;C:\EmployerReportGenerator\lib\emp-model.jar;C:\EmployerReportGenerator\lib\ghost4j-0.5.0.jar;C:\EmployerReportGenerator\lib\commons-io-1.3.1.jar;C:\EmployerReportGenerator\lib\jna-platform-4.0.0.jar;C:\EmployerReportGenerator\lib\log4j-1.2.15.jar;C:\EmployerReportGenerator\lib\xmlgraphics-commons-1.4.jar;C:\EmployerReportGenerator\lib\commons-beanutils-1.8.3.jar;C:\EmployerReportGenerator\lib\commons-logging-1.1.1.jar;C:\EmployerReportGenerator\lib\itext-2.1.7.jar;C:\EmployerReportGenerator\lib\jna-3.3.0.jar;C:\projects\det\lib\jasperreports-1.2.8.jar;C:\projects\det\release\PDFGeneratorService-client-1.0.jar;C:\TBO\DependentJars\ojdbc14.jar;C:\oracle\oc4j10.1.3.2\j2ee\home\applib\rdbthin.jar;C:\projects\det\release\xmlcomon-1_0.jar;C:\projects\det\release\jet-3_0.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\ejb-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\jca-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\jms-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\jsp-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\jta-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\servlet-api.jar;C:\eclipse\configuration\org.eclipse.osgi\bundles\797\1\.cp\lib\j2ee-1.3\sql-api.jar;C:\eclipse\plugins\org.junit_4.10.0.v4_10_0_v20120426-0900\junit.jar;C:\eclipse\plugins\org.hamcrest.core_1.1.0.v20090501071000.jar;C:\projects\det\lib\commons-logging-1.1.jar/C:/eclipse/configuration/org.eclipse.osgi/bundles/346/1/.cp//C:/eclipse/configuration/org.eclipse.osgi/bundles/979/1/.cp/
j、 lib.path:C:\Program Files\Java\jrockit-jre1.6.0\u 33-R28.2.4\bin;C:\Windows\system32;C:\Windows;C:\app\tfirmino\product\11.2.0\client\u 1;C:\app\tfirmino\product\11.2.0\client\u 1\bin;C:\oracle\product\10.2.0\client\u 1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramFiles(x86)\QuickTime\QTSystem\;C:\ProgramFiles(x86)\Common Files\GTK\2.0\bin;C:\ProgramFiles(x86)\cvsnt;C:\ProgramFiles\Internet Explorer;C:\ProgramFiles(x86)\SSH Communications Security\SSH Secure Shell;C:\ProgramFiles\SlikSvn\bin;C:\ProgramFiles(x86)\Sybase\Shared\PowerBuilder\;C:\ProgramFiles(x86)\SSH Communications Security\SSH Secure Shell;C:\Users\thais.firmino\Application Data\SSH\UserKeys;C:\Python27;C:\ProgramFiles\apache-maven-3.0.5\bin;C:\ProgramFiles\Java\jdk1.7.0_17\bin;;。
JAVA_主页:C:\Program Files\JAVA\jdk1.7.0_17\
_JAVA_选项:
路径:C:\app\tfirmino\product\11.2.0\client\u 1;C:\app\tfirmino\product\11.2.0\client\u 1\bin;C:\oracle\product\10.2.0\client\u 1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramFiles(x86)\QuickTime\QTSystem\;C:\ProgramFiles(x86)\Common Files\GTK\2.0\bin;C:\ProgramFiles(x86)\cvsnt;C:\ProgramFiles\Internet Explorer;C:\ProgramFiles(x86)\SSH Communications Security\SSH Secure Shell;C:\ProgramFiles\SlikSvn\bin;C:\ProgramFiles(x86)\Sybase\Shared\PowerBuilder\;C:\ProgramFiles(x86)\SSH Communications Security\SSH Secure Shell;C:\Users\thais.firmino\Application Data\SSH\UserKeys;C:\Python27;C:\ProgramFiles\apache-maven-3.0.5\bin;C:\ProgramFiles\Java\jdk1.7.0\U 17\bin;
StackOverFlow:发生了0个StackOverflowers错误
OutOfMemory:发生了0个OutOfMemory错误
C:好;没有内存分配失败
GC策略:模式:吞吐量,策略:genparpar(基本策略:genparpar)
GC状态:OC未运行。最后完成的OC是OC#0。
:YC未运行。最后完成的YC是YC#0。
有什么想法吗? 提前谢谢大家,,
泰国人

我的想法是,我的问题在某种程度上与上面提到的windows操作系统上的UAC有关,但按照建议进行更改并没有解决问题。 无论如何,通过一个变通办法,我解决了我的问题。请参见下文,我使用的是核心API,而不是高级API:

public void convert() {

        //get Ghostscript instance
        Ghostscript gs = Ghostscript.getInstance();

        File file= new File (this.getClass().getResource( "/resources/employer_report_last_page2.ps").getFile());//(Config.EMP_REPORT.REPORT_LAST_PAGE_STORE_PATH);
       // File file= new File (this.getClass().getResource( "/resources/Issues.ps").getFile());

        //prepare Ghostscript interpreter parameters
        //refer to Ghostscript documentation for parameter usage
        String[] gsArgs = new String[10];
        gsArgs[0] = "-ps2pdf";
        gsArgs[1] = "-dNOPAUSE";
        gsArgs[2] = "-dBATCH";
       gsArgs[3] = "-dSAFER";
        gsArgs[4] = "-sDEVICE=pdfwrite";
        gsArgs[5] = "-sOutputFile=output2.pdf";//output file name
       // gsArgs[5] = "-sOutputFile=" + file.getAbsolutePath();
        gsArgs[6] = "-c";
        gsArgs[7] = ".setpdfwrite";
        gsArgs[8] = "-f";
       // gsArgs[9] = "input.ps";//input file name
        gsArgs[9] = file.getAbsolutePath();//input file name

        //execute and exit interpreter
        try {

            gs.initialize(gsArgs);               
            gs.exit();

        } catch (GhostscriptException e) {
            System.out.println("ERROR: " + e.getMessage());
        }
 }
公共同步