Project

Profile

Help

Bug #3898

closed

Disable JAXP service provision

Added by Michael Kay over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
JAXP Java API
Sprint/Milestone:
-
Start date:
2018-09-07
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.8, trunk
Fix Committed on Branch:
9.8, trunk
Fixed in Maintenance Release:
Platforms:

Description

See https://stackoverflow.com/questions/52226236/saxon-only-validates-schemas-for-us

When an application tries to find a JAXP SchemaFactory, and Saxon-EE is on the classpath, but there is no license file, Saxon crashes out saying license not found, rather than responding to the request isSchemaLanguageSupported() with "false". It would be friendlier to respond "false".

We could also consider other ways of enabling applications to influence this. For example, we could have a static switch SchemaFactoryImpl.disableFactory() which sets a static variable causing isSchemaLanguageSupported() to return false. Static variables are pretty horrible, but the whole of JAXP is horrible and it might be the best we can do.

Actions #1

Updated by Michael Kay over 5 years ago

There's another thing that occurs to me here, which is that the OEM activation mechanism is never going to work with an application that uses the JAXP SchemaFactory approach to load Saxon, because the EnterpriseConfiguration object is created by the JAXP factory invocation without any involvement by the application. So disabling the JAXP invocation in that scenario makes perfect sense; if you want Saxon validation, you're going to have to use a different API anyway (if you really like JAXP interfaces, you can use new SchemaFactoryImpl(config) where config is a Configuration that you have already initialized.)

Actions #2

Updated by Michael Kay over 5 years ago

  • Category set to JAXP Java API
  • Status changed from New to Resolved
  • Priority changed from Low to Normal
  • Applies to branch 9.8, trunk added
  • Fix Committed on Branch 9.8, trunk added

I have made some changes (on the 9.8 and 9.9 branches) though it really needs a complete build to test them properly:

(a) you can now set the static flag SchemaFactoryImpl.ENABLED = false which will cause the SchemaFactoryImpl to return false in response to isSchemaLanguageSupported(), thus allowing you to have Saxon on the classpath without it muscling in on JAXP schema validation requests.

(b) if isSchemaLanguageSupported()` is called when there is no license file available, it will return false rather than crashing out with a LicenseException. This basically means that the JAXP search mechanism only considers using Saxon if both the JAR file and the license key are on the classpath.

(c) for 9.9 only, the SchemaFactoryImpl can be customized with a static method setConfigurationFactory(() -> EnterpriseConfiguration) which tells the SchemaFactory how to create/initialize a suitable Configuration object. This hook can be used for example for reading a configuration file, for setting properties on the configuration, or for supplying an OEM license key.

I'm departing from precedent here by having mutable static state, but it seems the best way to ameliorate the ill-thought out consequences of the JAXP mechanisms.

Actions #3

Updated by David Thielen over 5 years ago

I have an additional suggestion. If you are passed more than 1 license (multiple apps using Saxon), either programatically and/or with a .lic file, then set the functionality of Saxon to the union of all the license keys. Because you don't know on any given call which app's license should be used.

Actions #4

Updated by Michael Kay over 5 years ago

Interesting idea. The logic in this area is fairly tortuous already (and hard to test!) so it would require careful thought.

Actions #5

Updated by David Thielen over 5 years ago

Interesting idea. The logic in this area is fairly tortuous already (and hard to test!) so it would require careful thought.

That's why I suggested union all the permissions. So you can run as though you have one license.

Another question - do you want to post the above in Stack Overflow as the answer? Or would you like me to?

Actions #6

Updated by David Thielen over 5 years ago

Sorry, one last question. Any estimate as to when their will be a new release with the above addition?

thanks - dave

Actions #7

Updated by O'Neil Delpratt over 5 years ago

  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.9.0.1 added

Bug fix applied in the Saxon 9.9.0.1 major release.

Leave open until fix applied in the next Saxon 9.8 maintenance release.

Actions #8

Updated by David Thielen over 5 years ago

Hi O'Neil;

Any estimate on when the 9.8 maintenance release will be?

thanks - dave

Actions #9

Updated by O'Neil Delpratt over 5 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.8.0.15 added

Bug fix applied in the Saxon 9.8.0.15 maintenance release.

Please register to edit this issue

Also available in: Atom PDF