简体   繁体   English

Ghost4J-EXCEPTION_ACCESS_VIOLATION(JVM崩溃)

[英]Ghost4J - EXCEPTION_ACCESS_VIOLATION (JVM is crashing)

I'm trying to replace the PDF converter we are using in the company, but I'm getting this issue with Ghost4J. 我正在尝试替换公司中使用的PDF转换器,但是Ghost4J却遇到了这个问题。 Note my code is very similar to the sample they provide... 请注意,我的代码与他们提供的示例非常相似...

I'm using Java SE 1.6 (jrockit-jre1.6.0_33-R28.2.4) and Ghostscript 9.10 for Win 64 bits. 我正在将Java SE 1.6(jrockit-jre1.6.0_33-R28.2.4)和Ghostscript 9.10用于Win 64位。

My code is: 我的代码是:

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);
        }
    }

The JVM crash, that occurs on "converter.convert(document, fos);" JVM崩溃,发生在“ converter.convert(document,fos);”上 displays on the dump file the message: 在转储文件上显示以下消息:

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.        

Any ideas? 有任何想法吗? Thank you in advance, Thais 预先谢谢泰国人

My thoughts is that my issue is related in someway to UAC on windows OS as mentioned on http://www.java.com/en/download/help/exception_access.xml , but changing as suggested didn't solve the issue. 我的想法是,我的问题在某种程度上与Windows OS上的UAC有关,如http://www.java.com/en/download/help/exception_access.xml所述 ,但按建议进行更改并不能解决问题。 Anyway, through a workaround I got my issue solved. 无论如何,通过一种变通办法,我的问题得以解决。 See below I'm using the core API instead of the high level one: 参见下文,我使用的是核心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());
        }
 }

public synchronized void convertPostScriptToPDF() 公共同步void convertPostScriptToPDF()

or 要么

public void convertPostScriptToPDF() { synchronized(this) { ... } } 公共无效convertPostScriptToPDF(){已同步(this){...}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM