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:
>
>     
> PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Applications/OpenOffice.org.app/Contents/program
>       
>
> doing "which soffice" yields successfully:
>
>     /Applications/OpenOffice.org.app/Contents/program/soffice
>       
>
> ... and because it did not change the behaviour added a UNO_PATH
> environment variable:
>
>     UNO_PATH=/Applications/OpenOffice.org.app/Contents/program
>       
>
> The jar-files seem to have been found (as it is possible to load and use
> the "com.sun.star.comp.helper.Bootstrap" Java class. Here the shell
> script to set the environment:
>
>     export PATH=$PATH:/Applications/OpenOffice.org.app/Contents/program
>
>     
> OOOJAVA=/Applications/OpenOffice.org.app/Contents/basis-link/ure-link/share/java
>     export 
> CLASSPATH=$CLASSPATH:$OOOJAVA/juh.jar:$OOOJAVA/jurt.jar:$OOOJAVA/ridl.jar:$OOOJAVA/java_uno.jar:$OOOJAVA/unoloader.jar
>
>     export 
> DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/OpenOffice.org.app/Contents/basis-link/ure-link/lib
>       
>
> This is about running a program that works on Windows and various Linuxes.
>
> As MacOSX has quite a few "specific needs" applications reside in a
> directory (shown as a single file) under /Applications. Looking into
> OpenOffice.org.app the structure includes symbolic links (looking like
> criss-cross, but within the OpenOffice.org.app subdirectories).
>
> Maybe there is some little piece of information missing, to get
> com.sun.star.comp.helper.Bootstrap's bootstrap method to find its
> executable?
>
> Would you have any ideas, pointers, links that I could experiment with?
>
> TIA
>
> ---rony
>
> P.S.: here's the "uname -a" output in case it matters (MacOSX 10.6.6):
>
>     Darwin abt-wi-031.wu-wien.ac.at 10.6.0 Darwin Kernel Version 10.6.0: Wed 
> Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386
>       
>
>   

Reply via email to