LibreOffice / noa-libre

UNO API of LibreOffice easy and understandable - Nice Office Access
GNU Lesser General Public License v2.1
37 stars 21 forks source link

Connection test fails even if office path is correct #3

Closed anti43 closed 8 years ago

anti43 commented 8 years ago
C:\\Program Files (x86)\\LibreOffice 4\\URE\\java
C:\\Program Files (x86)\\LibreOffice 4\\program\\classes
Updating property file: C:\Users\andreas\Documents\noa-libre\build\built-jar.properties
Compiling 1 source file to C:\Users\andreas\Documents\noa-libre\build\classes
warning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning
compile-single:
run-single:
com.sun.star.comp.helper.BootstrapException: no office executable found!
    at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:266)
    at Lo4ConnectionTest.main(Lo4ConnectionTest.java:25)
xbubli commented 8 years ago

This happened to me in Eclipse, too, the reason being LibreOffice plays its own classloader games and Eclipse doesn't like it (I'm not familiar with Netbeans, it might be the same there).

I've been unable to solve the issue programmatically, classpath in manifest prevents ClassDefNotFound exceptions from happening, but doesn't help wih this 'office executable not found' issue. The only thing I was able to do was to add officebean jar (possibly also URE jars) to runtime classpath in Eclipse.

xbubli commented 8 years ago

@anti43: How does one run the connection test (in NetBeans or elsewhere)? How does the classpath look like? It would be helpful to know which classloader is being used when it fails, so if you can add some System.out.println(Bootstrap.class.getClassloader().getClass().getName()) to some appropriate place in the test and paste here what it prints ... I might have a way or two to work around the issue, but that one'll have to be implemented in libreoffice core

anti43 commented 8 years ago

Hi,

It prints 'sun.misc.Launcher$AppClassLoader' when run in Lo4ConnectTest2.java (has a main method)

nobisno commented 8 years ago

Hi I solved the issue in eclipse by adding the path to ...LibreOffice/program as an external class folder to my project (in project properties/libraries) and I also deleted the Classpath in die manifest file.

xbubli commented 8 years ago

With the new OfficeLoader, this should no longer be an issue, as long as the app using noa is started through OfficeLoader::run() which stands a fair chance of finding some UNO on the system (if not, one can always specify it the noa-way through IOfficeApplication.*_HOME_KEY)

See src/Lo4ConnectionTest.java on how to do that. One needs two separate classes, or 1 top-level and 1 nested class, the former will call main() method of the latter with the help of OfficeLoader::run.

Gotcha: when rebuilding noa, delete any stale manifest.mf that might still be around.