Project

Profile

Help

Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key

Added by Kiran Ainani almost 2 years ago

Hi, I'm currently using Saxon Evaluation key and before purchasing the license. We use XSLTs with Java calls extensive in the application and I'm currently having issue in translation them. While it is able to locate the java class and read the file but it is not able to find a matching method. Appreciate if you could provide any help on this.

Thank you.


Replies (17)

Please register to reply

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Michael Kay almost 2 years ago

It looks to me as if it succeeded in finding a method to call, and called it at run time, but the method crashed out with an exception. We can't tell from the diagnostics supplied which method it was calling when it crashed. The InvocationTargetException is a wrapper around the actual exception that the method threw; I would expect to see that "root cause" exception lower down the stack trace under the heading "caused by". If you point the debugger at the Java code of the various extension functions you should be able to see what's going wrong.

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Kiran Ainani almost 2 years ago

Hi Michael,

Thank you for your response.
I thought of that too and tried to run it in debug mode but the method in
xslt file never gets executed.
This is the error in Caused By

Caused by: java.lang.NoClassDefFoundError: org.dom4j.Document
[6/22/22 4:56:10:897 CDT] 000000ad SystemErr R at
net.sf.saxon.option.dom4j.DOM4JObjectModel.isRecognizedNodeClass(DOM4JObjectModel.java:161)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.option.dom4j.DOM4JObjectModel.getPJConverter(DOM4JObjectModel.java:88)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.expr.PJConverter.allocate(PJConverter.java:220)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
com.saxonica.expr.JavaExtensionFunctionCall.typeCheck(JavaExtensionFunctionCall.java:216)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.style.StyleElement.typeCheck(StyleElement.java:1578)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.style.SourceBinding.postValidate(SourceBinding.java:389)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.style.XSLGlobalVariable.postValidate(XSLGlobalVariable.java:91)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.style.StyleElement.validateSubtree(StyleElement.java:1765)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.style.PrincipalStylesheetModule.preprocess(PrincipalStylesheetModule.java:401)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.style.Compilation.compilePackage(Compilation.java:290)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:249)
[6/22/22 4:56:10:898 CDT] 000000ad SystemErr R at
net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:113)
[6/22/22 4:56:10:899 CDT] 000000ad SystemErr R at
net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:932)
[6/22/22 4:56:10:899 CDT] 000000ad SystemErr R at
net.sf.saxon.jaxp.SaxonTransformerFactory.newTemplates(SaxonTransformerFactory.java:155)

On Wed, Jun 22, 2022 at 3:39 AM Saxonica Developer Community <
> wrote:

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Michael Kay almost 2 years ago

OK, thanks for the extra info. This shows that the failure is actually while type-checking the call to the extension function. (So it has found the function OK, and is now doing the next stage of analysing it and preparing to call it.)

The type checker for some reason is confused about whether it should be checking to see if the extension function parameters include DOM4J objects. It shouldn't attempt this check unless DOM4J is on the classpath; but it is attempting it, and the attempt is failing because DOM4J isn't on the classpath. I can't immediately see how that condition can arise.

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Kiran Ainani almost 2 years ago

Hi,

I added the dom4j in the classpath and it now seems to work but I'm just
confused why it didnt work before as dom4j was added as maven dependency is
added in the project.
Is there any way we could move Saxon EE and the license off the classpath ?
I'm aware Saxon EE is not available under maven .

Thank you.

On Wed, Jun 22, 2022 at 6:34 AM Saxonica Developer Community <
> wrote:

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Norm Tovey-Walsh almost 2 years ago

I added the dom4j in the classpath and it now seems to work but I'm just
confused why it didnt work before as dom4j was added as maven dependency is
added in the project.
Is there any way we could move Saxon EE and the license off the classpath ?
I'm aware Saxon EE is not available under maven .

You can get Saxon EE from Maven on our repository:

https://dev.saxonica.com/maven/

If you add that repository to your build environment, you can then get
Saxon EE with the coordinates

com.saxonica:Saxon-EE:{version}

You can browse the repository to see what versions are available, but
all of the recent ones should be.

If you have any problems, please let me know.

Be seeing you,
norm

P.S. You’ll still need to put the license file somewhere that Saxon EE
can find it.

--
Norm Tovey-Walsh
Saxonica

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Kiran Ainani almost 2 years ago

Hi,

  1. I would have to check with our team if we can add the new repository url
    for Saxon EE in our project. We are in process of purchasing the Saxon EE
    license but still waiting for some approvals.
  2. You mentioned that the License file needs to be added in the project .
    Would that still be the classpath?

Thank you.
Kiran

On Thu, Jun 23, 2022 at 3:54 AM Saxonica Developer Community <
> wrote:

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Norm Tovey-Walsh almost 2 years ago

1 I would have to check with our team if we can add the new repository url
for Saxon EE in our project. We are in process of purchasing the Saxon EE
license but still waiting for some approvals.

If you have a problem adding another external repository, you could add
your own local, internal one, either on a server of your own or on the
local filesystem.

2 You mentioned that the License file needs to be added in the project .
Would that still be the classpath?

Yes. (In practice, I think there are some other options if you’re
willing to call configuration methods, but the classpath is the simplest.)

Be seeing you,
norm

--
Norm Tovey-Walsh
Saxonica

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Kiran Ainani almost 2 years ago

Hi,

My team was able to add Saxon URL under our artifactory so now we are able
to download Saxon EE as maven dependency.
However, I now get the following error while performing translations:

Caused by: javax.xml.transform.TransformerFactoryConfigurationError:
Provider com.saxonica.EnterpriseTransformerFactory not found
[7/12/22 7:02:58:587 CDT] 000000ab SystemErr R at
javax.xml.transform.TransformerFactory.newInstance(Unknown Source)
[7/12/22 7:02:58:588 CDT] 000000ab SystemErr R
xslt.translation.StylesheetCache.newTransformer(StylesheetCache.java:217)

I have added evaluation license key in Classpath.

Appreciate your help on this.

Regards,
Kiran Ainani

On Thu, Jun 23, 2022 at 7:05 AM Saxonica Developer Community <
> wrote:

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Kiran Ainani almost 2 years ago

Hi,

Sorry, I missed adding the property in my email before. I have set the
following system property:

System.setProperty("javax.xml.transform.TransformerFactory","com.saxonica.EnterpriseTransformerFactory");

Regards,
Kiran Ainani

On Tue, Jul 12, 2022 at 7:16 AM Kiran Ainani
wrote:

Hi,

My team was able to add Saxon URL under our artifactory so now we are able
to download Saxon EE as maven dependency.
However, I now get the following error while performing translations:

Caused by: javax.xml.transform.TransformerFactoryConfigurationError:
Provider com.saxonica.EnterpriseTransformerFactory not found
[7/12/22 7:02:58:587 CDT] 000000ab SystemErr R at
javax.xml.transform.TransformerFactory.newInstance(Unknown Source)
[7/12/22 7:02:58:588 CDT] 000000ab SystemErr R
xslt.translation.StylesheetCache.newTransformer(StylesheetCache.java:217)

I have added evaluation license key in Classpath.

Appreciate your help on this.

Regards,
Kiran Ainani

On Thu, Jun 23, 2022 at 7:05 AM Saxonica Developer Community <
> wrote:

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Michael Kay almost 2 years ago

The correct class name is com.saxonica.config.EnterpriseTransformerfactory.

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Kiran Ainani almost 2 years ago

Hi,

It is still the same.

Caused by: javax.xml.transform.TransformerFactoryConfigurationError:
Provider com.saxonica.config.EnterpriseTransformerfactory not found
[7/12/22 8:47:18:853 CDT] 000000b7 SystemErr R at
javax.xml.transform.TransformerFactory.newInstance(Unknown Source)

On Tue, Jul 12, 2022 at 7:32 AM Saxonica Developer Community <
> wrote:

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Michael Kay almost 2 years ago

Provider com.saxonica.config.EnterpriseTransformerfactory not found

Sorry, my typo. It's a capital "F" for Factory.

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Kiran Ainani almost 2 years ago

Hi,

That fixed it. Now, my JVM crashes everytime it is trying to perform a
translation. It creates huge dump files and I can see segmentation error.
I have added a license file and Saxon EE jar in the classpath.
I had the same problem initially but that was fixed after I added the above
files in classpath.

Thank you.
Regards,
Kiran

On Tue, Jul 12, 2022 at 8:53 AM Saxonica Developer Community <
> wrote:

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Kiran Ainani almost 2 years ago

Hi,

I was able to fix the error. I had missed setting up some of the parser
property.
Thank you for your assistance in this matter.

Regards,
Kiran

On Thu, Jul 14, 2022 at 5:43 PM Saxonica Developer Community <
> wrote:

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Kiran Ainani over 1 year ago

Hi,

We have purchased Enterprise License and added the license file in
CLASSPATH as well.
In my project , I have created a Transformer Factory as follows and setting
the following FEATURE.

TransformerFactory transFact = TransformerFactory.newInstance();
transFact.setAttribute(Feature.TRACE_EXTERNAL_FUNCTIONS.name, true);

I also included SAXON HE as a maven dependency, along with Saxon EE

Now, this worked as expected in my local/dev environment , but it throws
the following exception when I deployed to Test.

Surprisingly, it worked when I removed Saxon HE from my project, which I
dont understand could be the issue? Doesn't Saxon EE take precedence if it
finds a license file in lLasspath?

Caused by: java.lang.NullPointerException
[7/31/22 22:16:09:080 CDT] 000000db SystemErr R at
com.saxonica.config.ProfessionalConfiguration.setFeature(ProfessionalConfiguration.java:266)
[7/31/22 22:16:09:080 CDT] 000000db SystemErr R at
com.saxonica.config.EnterpriseConfiguration.setFeature(EnterpriseConfiguration.java:267)
[7/31/22 22:16:09:080 CDT] 000000db SystemErr R at
net.sf.saxon.Configuration.setConfigurationProperty(Configuration.java:4213)
[7/31/22 22:16:09:081 CDT] 000000db SystemErr R at
com.saxonica.config.ProfessionalConfiguration.setConfigurationProperty(ProfessionalConfiguration.java:226)
[7/31/22 22:16:09:081 CDT] 000000db SystemErr R at
net.sf.saxon.Configuration.setBooleanProperty(Configuration.java:4862)
[7/31/22 22:16:09:081 CDT] 000000db SystemErr R at
net.sf.saxon.jaxp.SaxonTransformerFactory.setFeature(SaxonTransformerFactory.java:550)
[7/31/22 22:16:09:081 CDT] 000000db SystemErr R at
cat.dcs.pip.xslt.translation.StylesheetCache.newTransformer(StylesheetCache.java:227)
[7/31/22 22:16:09:081 CDT] 000000db SystemErr R at
cat.dcs.pip.xslt.translation.XSLTGenericTranslation.translate(XSLTGenericTranslation.java:354)
[7/31/22 22:16:09:081 CDT] 000000db SystemErr R at
cat.dcs.pip.xslt.translation.XSLTGenericTranslation.translateWithValidationUsingStream(XSLTGenericTranslation.java:510)
[7/31/22 22:16:09:081 CDT] 000000db SystemErr R at
cat.dcs.pip.xslt.translation.XSLTGenericTranslation.translateWithOutValidationUsingStream(XSLTGenericTranslation.java:286)
[7/31/22 22:16:09:081 CDT] 000000db SystemErr R at
cat.dcs.pip.xslt.translation.XSLTGenericTranslation.translateWithOutValidationUsingStream(XSLTGenericTranslation.java:257)
[7/31/22 22:16:09:081 CDT] 000000db SystemErr R at
cat.dcs.pip.tools.servlets.XSLTTranslatorServlet.translate(XSLTTranslatorServlet.java:553)

Can you please help me understand if that is the issue? Or, probably give
me some more information on it.

Thank you.

Regards,
Kiran.

On Fri, Jul 15, 2022 at 5:18 AM Kiran Ainani
wrote:

Hi,

I was able to fix the error. I had missed setting up some of the parser
property.
Thank you for your assistance in this matter.

Regards,
Kiran

On Thu, Jul 14, 2022 at 5:43 PM Saxonica Developer Community <
> wrote:

RE: Issue in Translating XML with Reflexive Function XSLT in Java with Saxon Evaluation Key - Added by Michael Kay over 1 year ago

It's less confusing if you start a new thread when you have a new problem...

Having both Saxon-HE and Saxon-EE on the classpath will cause all kinds of problems, because the Java VM will typically load an unpredictable mixture of HE and EE classes. The two JAR files contain classes with the same names but (in some cases) different content, because we use preprocessing directives to modify the code prior to compilation. You need to take Saxon-HE off the classpath.

    (1-17/17)

    Please register to reply