Bootstrap works sometimes, and then it doesn't

The Application Programming Interface and the OASIS Open Document Format

Bootstrap works sometimes, and then it doesn't

Postby brieweb » Mon Nov 02, 2020 10:18 am

I tried the following program and sometimes it work, and other times it does not. I am using LibreOffice. I hope I didn't commit a foul. What gives?

I get the following output sometimes.

[brian@localhost Text]$ java -jar simpleGraphics.jar
com.sun.star.comp.helper.BootstrapException: no office executable found!
at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:338)
at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:302)
at foo.FirstUnoContact.main(FirstUnoContact.java:9)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)


and other times, success

Connected to a running office ...
remote ServiceManager is available


Code: Select all   Expand viewCollapse view
public class FirstUnoContact {

    public static void main(String[] args) {
        try {
            // get the remote office component context
            com.sun.star.uno.XComponentContext xContext =
                com.sun.star.comp.helper.Bootstrap.bootstrap();

            System.out.println("Connected to a running office ...");

            com.sun.star.lang.XMultiComponentFactory xMCF =
                xContext.getServiceManager();

            String available = (xMCF != null ? "available" : "not available");
            System.out.println( "remote ServiceManager is " + available );
        }
        catch (java.lang.Exception e){
            e.printStackTrace();
        }
        finally {
            System.exit(0);
        }
    }
}
Libre Office 7 on Fedora 33
brieweb
 
Posts: 2
Joined: Mon Nov 02, 2020 10:12 am

Re: Bootstrap works sometimes, and then it doesn't

Postby RoryOF » Mon Nov 02, 2020 10:49 am

My immediate thought is that this might be some form of race condition, that failure occurs when the OpenOffice document is not fully ready. I suggest, as a trial measure, that you insert a delay loop into your Java code to allow the OO document stabilise before attempting to open the link from Java.
Apache OpenOffice 4.1.9 on Xubuntu 20.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 32401
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Bootstrap works sometimes, and then it doesn't

Postby brieweb » Mon Nov 02, 2020 10:43 pm

I created a second identical project (or so I believe) in in Eclipse and it gives the same "no office executable found!" error. I can run compile on the command line and it works fine. I wonder if the environment options are not making it to the IDE?
Brian
Libre Office 7 on Fedora 33
brieweb
 
Posts: 2
Joined: Mon Nov 02, 2020 10:12 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 3 guests