Reputation: 32926
We ship saxon with our library. We pass it the license in code and therefore do not ship the saxon-library.lic file. Our system all works great.
However, one of our customers has a problem where, when hazelcast (library they use) wants to validate a schema, as Saxon has registered itself as a javax.xml.validation.SchemaFactory provider, it uses Saxon. And fails because of no license.
So we need it to do this when we call, but not when other apps call. Or, if it's ok, we need to ship the .lic file with our app. Or is there another solution?
thanks - dave
Upvotes: 1
Views: 141
Reputation: 163342
There are two possible routes forward on this. One is to get the other application to use Saxon schema validation successfully, the other is to try and prevent it loading Saxon as the schema validator.
To achieve the first, it does need to have access to a license file, and we can discuss how this might best be achieved. As this might involve questions that are commercial/legal rather than purely technical, I think it would be better to discuss it offline.
To achieve the second, there are various ways that the JAXP algorithm for loading a SchemaFactory can be influenced. One is to use the SchemaFactory.newInstance() method that explicitly identifies the factory class required; another is to set the javax.xml.validation.SchemaFactory:schemaLanguage
system property. If all else fails, you could consider removing the entry from the Saxon JAR file (in META-INF) that identifies Saxon as a JAXP SchemaValidator service provider.
(That's what we ended up doing with the equivalent XPath factory registration: the JAXP search mechanism was causing so much trouble that we ended up saying, if you want Saxon as your XPath provider, load it directly from your application, don't just rely on it being the first thing found on the classpath).
The JAXP mechanism, which doesn't really allow for two parts of an application to have different dependencies, is a bit of a disaster, and I do wonder whether there is anything we could do to make it less so, short of just walking away from it entirely. One thing that does look feasible (subject to confirmation) is that the method isSchemaValidationSupported()
could return false, rather than crashing out, if no license is available. We could also consider some other external/global way of saying "don't use Saxon as a JAXP schema validator", for example a static variable or system property.
Issue added here: https://saxonica.plan.io/issues/3898
Upvotes: 1