Project

Profile

Help

Bug #5397

open

Upgrade to V 11.x : TransformerFactoryConfigurationError

Added by M. Hilpert 2 months ago. Updated about 2 months ago.

Status:
AwaitingInfo
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2022-03-16
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
11
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:
Java

Description

I upgraded wetn back and did smaller upgrade steps aI Saxon-HE (Java) from 9.9.6 to latest 11.2 and get

121835203 INFO T42: New transformer factory for specific implementation 'net.sf.saxon.TransformerFactoryImpl' ... 121835240 SEVERE T42: TransformerFactory implemenation 'net.sf.saxon.TransformerFactoryImpl' invalid (Provider net.sf.saxon.TransformerFactoryImpl could not be instantiated: java.lang.reflect.InvocationTargetException) - using default. 121835290 SEVERE T42: Unexpected error: javax.xml.transform.TransformerFactoryConfigurationError: Provider for class javax.xml.transform.TransformerFactory cannot be created javax.xml.transform.TransformerFactoryConfigurationError: Provider for class javax.xml.transform.TransformerFactory cannot be created at java.xml/javax.xml.transform.FactoryFinder.findServiceProvider(FactoryFinder.java:293) at java.xml/javax.xml.transform.FactoryFinder.find(FactoryFinder.java:247) at java.xml/javax.xml.transform.TransformerFactory.newInstance(TransformerFactory.java:126)

So, I went back to smaller increments and upgraded step by step by replacing saxon-he.jar. Up to 10.7, it still works, but starting with 11.1 I get the error above (it does not seem to find itself anymore).

Actions #1

Updated by Michael Kay 2 months ago

There are two possible approaches to diagnosing this, and we may need to try both.

The first is to get better diagnosis. At the moment it's just telling us that there was a failure instantiating the class, and it's not telling us what the failure was. I imagine a full stack trace of the failure would yield some insights. It's possible that setting the Java system property jaxp.debug="1" might give something, but I'm less confident of that. You could try instantiating net.sf.saxon.TransformerFactoryImpl directly from your application (using new TransformerFactoryImpl rather than TransformerFactory.newInstance() and see if that tells us anything.

The second approach is to provide enough information so we can reproduce the failure. For that we would need to see full details of how the TransformerFactory is being instantiated, including details of what's on the classpath, JDK version, and details of any application frameworks you are using.

My suspicion would be that there's something unusual about your class loading environment - perhaps security settings.

A minor point: the misspelling "implemenation" in the error message might provide some clues as to what software is trying to load Saxon and report the failure.

Actions #2

Updated by Michael Kay 2 months ago

Looking at the code of TransformerFactory, you should definitely get better diagnostics if you set jaxp.debug="1" (or any value other than "false")

Actions #3

Updated by Michael Kay about 2 months ago

  • Status changed from New to AwaitingInfo
Actions #4

Updated by M. Hilpert about 2 months ago

Tried "jaxp.debug" ... logs:

JAXP: find factoryId =javax.xml.transform.TransformerFactory
JAXP: found system property, value=net.sf.saxon.TransformerFactoryImpl
T77: TransformerFactory implemenation 'net.sf.saxon.TransformerFactoryImpl' invalid (Provider net.sf.saxon.TransformerFactoryImpl could not be instantiated: java.lang.reflect.InvocationTargetException) - using default.
JAXP: find factoryId =javax.xml.transform.TransformerFactory
Unexpected error: javax.xml.transform.TransformerFactoryConfigurationError: Provider for class javax.xml.transform.TransformerFactory cannot be created
    javax.xml.transform.TransformerFactoryConfigurationError: Provider for class javax.xml.transform.TransformerFactory cannot be created
    	at java.xml/javax.xml.transform.FactoryFinder.findServiceProvider(FactoryFinder.java:293)
    	at java.xml/javax.xml.transform.FactoryFinder.find(FactoryFinder.java:247)
    	at java.xml/javax.xml.transform.TransformerFactory.newInstance(TransformerFactory.java:126)

BTW: I just replaced the "saxon-he.jar" are there some new dependencies that could cause this error?

Actions #5

Updated by Michael Kay about 2 months ago

Is that the full stack trace? I would have expected a "Caused by" section identifying the exception that triggered the InvocationTargetException.

Have you tried instantiating net.sf.saxon.TransformerFactoryImpl directly (by simply doing "new net.sf.saxon.TransformerFactoryImpl()" from your Java code?

Actions #6

Updated by M. Hilpert about 2 months ago

The stack trace ends at the last internal line, all subsequent stack trace lines are from my application. No, I don't use specific saxon API calls, because I want to stay independent. We had months of conversion work to do to migrate the XSL code to work with saxon (because we had lots of errors / non-standard code that did not cause problems with Xalan). So we need to stay independent and just set the implementation that we test.

Actions #7

Updated by Michael Kay about 2 months ago

I'm not saying you should be using direct instantiation in your target application, I'm just asking you to try it to see if it yields any diagnostic insights. If it fails, there's a good chance that we will get a better indication of why it's failing. If it succeeds, then that also gives us insights.

Actions #8

Updated by Michael Kay about 2 months ago

I'm wondering if it's perhaps caused by not having the xmlresolver JAR available?

This doesn't normally need to be added to the classpath explicitly because it's referenced in the manifest of the main saxon JAR. But if you've moved the main saxon JAR to a different location, and didn't copy the resolver JAR at the same time, then I think you could see some kind of loading failure like this.

Actions #9

Updated by M. Hilpert about 2 months ago

I tried this:

Object o = new net.sf.saxon.TransformerFactoryImpl();

but Eclipse shows "net cannot be resolved to a type". Yes, I added the JARs to the classpath, rebuild/refresh, even tried older saxon-he versions. Just simple type "net." does not show anything (but "org." shows all the packages of the classpath.

Actions #10

Updated by Michael Kay about 2 months ago

The Eclipse configuration is probably completely different to the configuration in which you're seeing the failure, so that's not going to tell us much. We would only learn anything if you do this in exactly the same environment as where you're seeing the failure.

Actions #11

Updated by M. Hilpert about 2 months ago

... progress: after adding the "xmlresolver.jar", the original error vanished. So you were right that this JAR was missing as a required dependency (for Saxon 11). However, even with this working code,

 Object o = new net.sf.saxon.TransformerFactoryImpl();

still does not work (see above).

So, it would be usefull to have required dependencies somewhere in a readme file (we never throw all JARs of third party libraries all together, but only the minimum we need.

This would be a good message, but due to several other errors we get after introducing Saxon V 10 (as V11 had this eeror in our case) - e.g. Bug #5398 - we had to revert to Saxon V 9 until we find time to inspect all the new errors we get after switching from V 9 to V 10.

Actions #12

Updated by Norm Tovey-Walsh about 2 months ago

Hello,

The XML Resolver jars are listed as required dependencies in the Maven
POM, but I take your point about making the dependency clearer in the
documentation.

Be seeing you,
norm

--
Norm Tovey-Walsh
Saxonica

Please register to edit this issue

Also available in: Atom PDF