RuntimeException: [msci_uno bridge error] UNO type of C++ ex

The Application Programming Interface and the OASIS Open Document Format

RuntimeException: [msci_uno bridge error] UNO type of C++ ex

Postby groverblue » Mon Apr 25, 2011 9:34 pm

I have a muti-threaded application that processes document mostly asynchronous. I synchronize all UnoRuntime.* API calls, but not such calls as setting a table cell's value, etc. Everything runs fine in development, qa and in a production environment for one our clients. We have another client, however, where we are experience a complete breakdown. While processing, we continually get the following exception. Both clients are running version 3.3 of OpenOffice/UNO. Has anyone experienced this or is there a way to get more information/debug OpenOffice?

Here is how OpenOffice is launched from bootstrapconnector:
C:\Program Files\OpenOffice.org 3\program\soffice.exe -nologo -nodefault -norestore -nocrashreport -nolockcheck -headless -nofirststartwizard -accept=pipe,name=uno3869894507064209706;urp;

Here is the RuntimeException:
Code: Select all   Expand viewCollapse view
com.sun.star.uno.RuntimeException: [msci_uno bridge error] UNO type of C++ exception unknown: "std.bad_alloc", RTTI-name=".?AVbad_alloc@std@@"!
   at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:177)
   at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:143)
   at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:335)
   at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:304)
   at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:91)
   at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:639)
   at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:151)
   at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:133)
   at $Proxy27.storeToURL(Unknown Source)
   at com.company.ooo.FileManager.componentExport(FileManager.java:135)
   at com.company.util.PDFGenerator.generatePDF(PDFGenerator.java:183)
   at com.company.util.PDFGenerator.generateSinglePDFFromDocumentList(PDFGenerator.java:106)
   at com.company.service.processor.DefaultPDFStoreServiceProcessorNG.process(DefaultPDFStoreServiceProcessorNG.java:161)
   at com.company.service.DefaultPDFStoreService.process(DefaultPDFStoreService.java:38)
   at com.company.core.PrintServiceThread.run(PrintServiceThread.java:129)
Apr 25, 2011 9:59:16 AM com.company.util.SyslogUtil logEvent



I'm attempting to export a PDF file named C:/COMPANY/temp/d7255f23-f2da-42ad-972e-3fda3e42b066.pdf with the following:
Code: Select all   Expand viewCollapse view
public static void componentExport(XComponent xComponent, PropertyValue[] properties, String storeFile) throws DocumentException {
        XStorable xStorable = null;
        synchronized (accessLock) {
            try {
                xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xComponent);
                xStorable.storeToURL("file:///" + storeFile, properties);
            } catch (com.sun.star.uno.RuntimeException e) {
                xStorable = null;
                xRemoteContext = null;  // OOo will be relaunched
                xRemoteServiceManager = null;
                e.printStackTrace();
                throw new DocumentException("Failed to store file: " + storeFile, e);
            } catch (java.lang.Exception e) {
                xStorable = null;
                throw new DocumentException("Failed to store file: " + storeFile, e);
            }
        }
        xStorable = null;
    }


Code: Select all   Expand viewCollapse view
public class PDFGenerator {
    private PropertyValue[] pdfStoreProps;


    public PDFGenerator(){
            PropertyValue[] filterData = new PropertyValue[2];

            filterData[0] = new PropertyValue();
            filterData[0].Name = "UseLosslessCompression";
            filterData[0].Value = Boolean.FALSE;

            filterData[1] = new PropertyValue();
            filterData[1].Name = "ExportFormFields";
            filterData[1].Value = Boolean.FALSE;

            pdfStoreProps = new PropertyValue[4];
            pdfStoreProps[0] = new PropertyValue();
            pdfStoreProps[0].Name = "FilterName";
            pdfStoreProps[0].Value = DocumentType.WRITER_PDF_EXPORT;

            pdfStoreProps[1] = new PropertyValue();
            pdfStoreProps[1].Name = "Pages";
            pdfStoreProps[1].Value = "All";

            pdfStoreProps[2] = new PropertyValue();
            pdfStoreProps[2].Name = "Overwrite";
            pdfStoreProps[2].Value = Boolean.TRUE;

            pdfStoreProps[3] = new PropertyValue();
            pdfStoreProps[3].Name = "FilterData";
            pdfStoreProps[3].Value = filterData;
    }

    /**
     * Generates one PDF from all the documents
     * @param copies The number of document copies to be generated
     * @param documents A hashtable holding the documents as XComponent
     * @param path The folder where the PDF will be stored
     * @param fileName  The name of the PDF to be generated
     */

    public final PrintProcessStatus generateSinglePDFFromDocumentList(int copies,
                                                 LinkedList<TextDocumentReference> documents,
                                                 String path,
                                                 String fileName) {

        //sets up the save properties to save the documents as PDFs
        PrintProcessStatus returnStatus;

        if (!path.endsWith("/")) {
            path = path.concat("/");
        }

        PropertyValue[] loadProps = FileManager.createPropertyValueArray(
                FileManager.createPropertyValue("AsTemplate", new Any(Type.BOOLEAN, Boolean.TRUE)),
                FileManager.createPropertyValue("Hidden", new Any(Type.BOOLEAN, Boolean.TRUE)));

        ArrayList<String> PDFFiles = new ArrayList<String>();
        //Saves the Files out as PDFs and records the file names
        try {
            for (int count = 1; count <= copies; count++) {
                for (TextDocumentReference xc : documents) {
                    String filePath=null;
                    if (xc.getDocumentName().toLowerCase().endsWith(".pdf")){
                        filePath = xc.getDocumentName();
                    } else {
                        XComponent xcomp = FileManager.componentImport(xc.getDocumentName(), loadProps);
                        filePath = generatePDF(xcomp, path, null);
                        try {
                            FileManager.closeComponent(xcomp);
                        } catch (DisposedException de){
                            SyslogUtil.logEvent("Could not close document " + xc.getDocumentName(), de);
                        }
                    }
                    PDFFiles.add(filePath);
                }
            }
            // HERE - Generates a new PDF and combines all the PDFs into one
        } catch (Exception ex) {
            SyslogUtil.logEvent(null, ex);
            File f = new File(path + fileName + ".pdf");
            try {
                if (f.exists()) {
                    f.delete();
                }
            } catch (SecurityException e) {
                SyslogUtil.logEvent(null, ex);
            }
            f = null;
            returnStatus = PrintProcessStatus.FAILED;
        }

        //Deletes all the PDFs that were made from the documents           
        for (String s : PDFFiles) {
                File f = new File(s);
                try {
                    if (f.exists()) {
                        f.delete();
                    }
                } catch (SecurityException e) {
                    SyslogUtil.logEvent("Could not delete PDF file " + s, null);
                }
                f = null;
            }
        return returnStatus;
    }

    /**
     *
     * @param xc The XComponent to be saved as a PDF
     * @param directoryPath The directory path which the file will be stored
     * @param fileName The file name of the PDF.  If fileName is null, a unique Id will be generated
     * @return Returns the full file path (C:\somedirectory\somefile.pdf)
     */
    public String generatePDF(XComponent xc, String directoryPath, String fileName)
            throws com.sun.star.io.IOException, DocumentException {

        String realFileName = (fileName == null) ? UUID.randomUUID().toString() : fileName;
        String filePath = directoryPath + realFileName + ".pdf";
        try {
            FileManager.componentExport(xc, pdfStoreProps, filePath);
        } catch (DocumentException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new DocumentException(ex);
        }
        return filePath;
    }

}
groverblue
 
Posts: 40
Joined: Wed Mar 26, 2008 6:17 pm

Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 0 guests