Thanks for reporting this.
We certainly can't complain that the error message is terse or unclear!
The XQJ interface definitions are bundled into the main Saxon JAR
because they are not available in the JDK (even in Java 7) - the Android
developers appear to have made an incorrect assumption that any class in
the namespace javax.* is part of the JDK core.
It should be possible to avoid this problem by removing the XQJ
interfaces together with their implementations (package
net.sf.saxon.xqj) from the JAR file. That would give you a version of
Saxon that works, but with XQJ not available. One would like to think
that one could put the XQJ support into a separate JAR file, but I think
that loading this JAR file would fail for exactly the same reason. We
can't copy the XQJ interfaces into a different namespace because (apart
from affecting portability of applications) that would contravene the
XQJ license conditions. So at the moment the only way I can see of
delivering the XQJ functionality on android is to use the --core-library
option. I think their warnings about pain, suffering, grief and
lamentation can safely be ignored because although these classes have
javax.* names, they do not in fact conflict with any classes in the
core. (If and when XQJ does find its way into the JDK core, we can
remove the classes from the Saxon JAR). Give it a try, and let us know
how you get on.
On 28/04/2011 06:09, RB45F wrote:
> I'm trying to port some java code to android and found that saxon 184.108.40.206
> (saxon9he.jar) will not load, specifically because it includes one or more
> javax classes. The android build logic stops while compiling the project
> once the jar is added to the build path. The error message is pasted below.
> I'm using android version 2.2 (used by many smartphones now) in the latest
> version of Eclipse. Steps to reproduce:
> - install android plugin
> (http://developer.android.com/sdk/eclipse-adt.html) including api for
> version 2.2
> - create android project specifying version 2.2
> - add saxon jar to project
> I can't find any mention of android in this forum - are there any known
> workarounds? I tried manually deleting the javax classes from the saxon jar,
> but this caused a java heap space error during the jar import process. I
> could try the --core-library options mentioned below but that seems quite
> Any other ideas or advice on how I should proceed?
> -- here is the log message --
> trouble processing "javax/xml/xquery/ConnectionPoolXQDataSource.class":
> Ill-advised or mistaken usage of a core class (java.* or javax.*)
> when not building a core library.
> This is often due to inadvertently including a core library file
> in your application's project, when using an IDE (such as
> Eclipse). If you are sure you're not intentionally defining a
> core class, then this is the most likely explanation of what's
> going on.
> However, you might actually be trying to define a class in a core
> namespace, the source of which you may have taken, for example,
> from a non-Android virtual machine project. This will most
> assuredly not work. At a minimum, it jeopardizes the
> compatibility of your app with future versions of the platform.
> It is also often of questionable legality.
> If you really intend to build a core library -- which is only
> appropriate as part of creating a full virtual machine
> distribution, as opposed to compiling an application -- then use
> the "--core-library" option to suppress this error message.
> If you go ahead and use "--core-library" but are in fact
> building an application, then be forewarned that your application
> will still fail to build or run, at some point. Please be
> prepared for angry customers who find, for example, that your
> application ceases to function once they upgrade their operating
> system. You will be to blame for this problem.
> If you are legitimately using some code that happens to be in a
> core package, then the easiest safe alternative you have is to
> repackage that code. That is, move the classes in question into
> your own package namespace. This means that they will never be in
> conflict with core system classes. JarJar is a tool that may help
> you in this endeavor. If you find that you cannot do this, then
> that is an indication that the path you are on will ultimately
> lead to pain, suffering, grief, and lamentation.