Until OOo 2.2, all the jars from OOo itself (in the
program/classes directory) as well as all the jars from deployed extensions ended up on the one big global class path. This has changed dramatically with OOo 2.3, where the global class path is now empty. Unfortunately, some OOo extensions that worked just fine with OOo 2.2 stopped to work with OOo 2.3. The following are points OOo extension authors should be aware of, to produce well-behaved extensions that will work fine in any OOo:
First, if an extension contains multiple jars, dependencies among these jars need to be recorded in the
Class-Path entries of the jars'
META-INF/MANIFEST.MF files. This is general Java stuff.
Second, if an extension calls code that uses the context class loader (to load classes from your extension), the extension needs to set up an appropriate context class loader around those calls. All Greek to you? See below. This also is general Java stuff.
Third, for UNO to work properly, a jar should record in the
UNO-Type-Path entry of its
META-INF/MANIFEST.MF file whether it contains class files that represent UNO types. See
issue 80405 for (well hidden, for now) documentation. This is not general Java stuff, but rather is specific to the UNO framework.
Now, to the context class loader: There are Java libraries that dynamically load classes by name, for example
javax.xml.parsers.SAXParserFactory. When all those libraries have is a class name, where do they get a class loader from to call
loadClass? Out of thin air. Or rather, they call
Thread.getContextClassLoader to obtain such a class loader. If you do not set a specific one,
getContextClassLoader will normally return the application class loader (the one that works off the global class path). And that happened to be a wonderfully working default in OOo 2.2, where everything you would ever want to load was on the one big global class path, anyway. So nobody bothered to explicitly set a context class loader where needed (those are the perils of implicit arguments). And now those extension start to fail mystically with OOo 2.3, where the application class no longer knows how to load all those classes...
tags:
extensions
java
openoffice.org
Comments