Hi there,
went out and found some infos on Sun's documentation, but still
wouldn't know a solution to the problem. Here's the use case:
- a C/++ program loads and uses a Java class that resides in an
extension jar (copied to .../jre/lib/ext); that Java class is used to
invoke Java classes anywhere on the system using "Class.forName()" to
locate and load the classes (using "this.getClassLoader()"). In the
process that Java class will use JNI to invoke the ooRexx interpreter
(a C++ program) which executes a supplied Rexx script (using a DLL
which is copied to .../jre/lib/i386). Such Rexx programs are able to
call back into Java using JNI.
- Now, if a Java class should be located from a non-bootstrap/non
extension directory (using "Class.forName(string)" ) on behalf of the
Rexx script, this does not work. It seems that in this use case the
used classLoader seems to have no information about additional Java
classes pointed to by the CLASSPATH environment variable or the
appropriate "-Djava.class.path" startup option.
- .a Java-class is invoked which resides in the extension jar, uses
JNI to load the ooRexx-interpreter to execute a Rexx script, which
calls back into Java via JNI.
- So far it works.
- Now, if a Java class should be located from a non-bootstrap/non
extension directory (using "Class.forName(string)" ) on behalf of the
Rexx script, this does not
work. It seems that in this use case the used classLoader seems to have
no information about additional Java classes pointed to by the
CLASSPATH environment variable or the appropriate "-Djava.class.path"
startup option.
- In this case, *probably* (will try this in the next step) a
solution can be to move the Java-class that dispatches Rexx scripts
outside the extension directory, because that classLoader in use then
would be able to see the CLASSPATH directories/jars/zips.
Moving the jar and its matching DLL to another location solves the
problem in this case, *but* I would like to use the Java extension
mechanism as this would ease deployment where different applications
want to use the supplied functionality (one being OOo, of course).
Any ideas/hints highly appreciated (even if you can authoratively
state, that this problem for the one or the other use-cases cannot not
be solved).
TIA,
---rony
P.S.: The e-mail turnover time jumped up to a few hours, so maybe I
have not seen answers that have arrived before this e-mail got sent.
Rony G. Flatscher wrote:
Hi
Stephan,
have been running over a very strange
problem (RedHat Fedora Core 3, OOo 2.0.1 installed parallel to OOo
1.1.4): addressing OOo via Java (using a Java archive that itself uses
native code that uses JNI 1.2).
If setting up the environment (CLASSPATH, PATH, invoking java with
-Djava.library.path ) in a script everything works as expected. After
copying the jar-file to the Java extension directory
(/usr/java/j2sdk1.4.2_10/jre/lib/ext), the native DLL/so to the
respective extension directory (/usr/java/j2sdk1.4.2_10/jre/lib/i386),
all of a sudden using Java reflection the OOo UNO-Java-classes (barfs
on com.sun.star.beans.PropertyValue) cannot be found anymore (the stack
trace shows, that the jar-file, that was copied to the ext-directory
was found and used)!
If you move your code to the extension directory, then it is loaded by
the extension class loader. If your code then tries to naively find a
class (via Class.forName(String)) that is only loaded by a class loader
"derived" from the extension class loader (e.g., the application class
loader), that would naturally not work. (Check out
Class.forName(String, boolean, ClassLoader).)
Hmm, obviously I am missing some very importang, fundamental piece of
information here: why would the bootstrap ClassLoader not be able to
find the OOo-UNO class by name? Which ClassLoader do I need to use then
(and how to get at it) to locate the OOo-UNO-classes at runtime, so it
becomes irrespectible where I place my jar-file that needs to carry out
that operation?
Would you have any hints, pointers where to get that kind of
information w.r.t. OOo/UNO (so far I have been trying to have my code
be executable by evne Java 1.1.8, the ClassLoader came into being with
1.2 AFAICT, so please bear with me a little bit) ?
Any hints/pointers *highly* appreciated !
Regards,
---rony
P.S.: The code starts out with invoking classes in that jar-file which
is placed in the extension directory and needs to find/locate the
OOo/UNO classes from there. According to the docs the bootstrap
ClassLoader is being used for Class.forName(String). The missing piece
obviously is here for me: how to get at a ClassLoader that would be
able to locate any Java class in any jar-file installed at any location
in a system?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
|