Bootstrap works sometimes, and then it doesn't

The Application Programming Interface and the OASIS Open Document Format
Post Reply
brieweb
Posts: 2
Joined: Mon Nov 02, 2020 10:12 am

Bootstrap works sometimes, and then it doesn't

Post by brieweb »

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

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
User avatar
RoryOF
Moderator
Posts: 33647
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

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

Post by RoryOF »

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.13 on Xubuntu 22.04.1 LTS and very infrequently on Win2K/XP
brieweb
Posts: 2
Joined: Mon Nov 02, 2020 10:12 am

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

Post by brieweb »

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
Post Reply