Page 1 of 1

Bootstrap works sometimes, and then it doesn't

PostPosted: Mon Nov 02, 2020 10:18 am
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   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);
        }
    }
}

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

PostPosted: Mon Nov 02, 2020 10:49 am
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.

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

PostPosted: Mon Nov 02, 2020 10:43 pm
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