Partially solved!
The CLASSPATH-environment variable must also have the directory listed,
in which soffice resides. The shell script to create the needed
environment on Apple looks like:
UNO_PATH=/Applications/OpenOffice.org.app/Contents/program
export PATH=$PATH:$UNO_PATH
OOOJAVA=/Applications/OpenOffice.org.app/Contents/basis-link/ure-link/share/java
export
CLASSPATH=$CLASSPATH:*$UNO_PATH*:$OOOJAVA/juh.jar:$OOOJAVA/jurt.jar:$OOOJAVA/ridl.jar:$OOOJAVA/java_uno.jar:$OOOJAVA/unoloader.jar
It is now possible to start OOo employing the OOo Java APIs.
---
There is one problem (not occurring on Windows and Linux) left, which
maybe someone has an idea about:
[java.lang.reflect.InvocationTargetException], getCause():
[com.sun.star.lang.DisposedException: com.sun.star.uno.RuntimeException:
java.lang.ClassNotFoundException: com.sun.star.frame.XDesktop] \\\
BSF4ooRexx subfunction invoke: object 'java.lang.Class@1db699b' - method
[FINDINTERFACEWITHMEMBER], method not found or error (exception) executing
method!]]
The flow is as follows:
* after bootstrapping the received context is stored in a Java class
which uses the context later for reflection,
* then the com.sun.star.frame.Desktop service object is created
with that context,
* then the XDesktop interface is queried using reflection; this is
where the error occurs:
o unwrapping the wrapped exceptions (with getCause()) yields
the string:
+ com.sun.star.lang.DisposedException:
com.sun.star.uno.RuntimeException:
java.lang.ClassNotFoundException:
com.sun.star.frame.XDesktop
If it is a disposed exception, then the cached context or the service
object are candidates for that to occur. However, on Windows and Linux
this does not happen as there are (global) references to these Java
objects which should inhibit any disposals.
TIA,
---rony
On 15.02.2011 16:27, rony wrote:
On 15.02.2011 13:31, Stephan Bergmann wrote:
On 02/15/11 11:54, Rony G. Flatscher wrote:
trying to figure out the setup needs for OOo 3.3 on MacOSX, if wishing
to use Java from the commandline to bootstrap and work with OOo 3.3.
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Java/Transparent_Use_of_Office_UNO_Components
should be what you are looking for. Not sure how well the automatic
detection of an OOo installation part works on Mac OS X, but you can
always do that manually via the com.sun.star.lib.loader.unopath Java
system property.
Stephan, thank you very much for your link!
Unfortunately, it did not help.
Scenario: the program uses Java to load
com.sun.star.comp.helper.Bootstrap, which is found. Excercising then
the bootstrap method yields the following stack trace:
sch... UNEXPECTED error, cannot bootstrap and/or retrieve singletons!
*com.sun.star.comp.helper.BootstrapException: no office executable found!*
at com.sun.star.comp.helper.Bootstrap.bootstrap(Bootstrap.java:243)
at org.oorexx.uno.RgfReflectUNO.setContext(RgfReflectUNO.java:368)
at
org.oorexx.uno.RgfReflectUNO.findInterfaceWithMember(RgfReflectUNO.java:2387)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.rexxla.bsf.engines.rexx.RexxAndJava.invokeMethod(RexxAndJava.java:4826)
at
org.rexxla.bsf.engines.rexx.RexxAndJava.javaCallBSF(RexxAndJava.java:3590)
at org.rexxla.bsf.engines.rexx.RexxAndJava.jniRexxRunProgram(Native
Method)
at org.rexxla.bsf.engines.rexx.RexxEngine.apply(RexxEngine.java:833)
at org.rexxla.bsf.RexxDispatcher.main(RexxDispatcher.java:134)
RexxDispatcher.java: Throwable of type
'org.rexxla.bsf.engines.rexx.RexxException' thrown while invoking Rexx:
getLocalizedMessage(): [BSF4ooRexx/routine/jniRexxRunProgram(), error 9:
1805 *-* return uno.wrap( .uno~rgfReflectUNO~findInterfaceWithMember(
o, name, bReturnString, howMany, .uno~bExtendSearch) )
Error 40 running /usr/bin/UNO.CLS line 1805: Incorrect call to routine
Error 40.900: BSF4ooRexx/routine/BSF(), error 3: Java exception
occurred: [org.apache.bsf.BSFException: /// Java-exception (RexxAndJava)
occurred: [java.lang.reflect.InvocationTargetException], getCause():
[java.lang.NullPointerException] \\\
BSF4ooRexx subfunction invoke: object 'java.lang.Class@196c1b0' -
method [FINDINTERFACEWITHMEMBER], method not found or error (exception)
executing method!]]
Now according to the description in the wiki your link points to, I
added the path to soffice to PATH: