Page 1 of 1

XSLT javax.mail.MessagingException

Posted: Fri Feb 26, 2021 7:42 am
by Fiona Chen
Hello:
Not sure if this is can be resolved in SAXON or Oxygen's realm.
The XSLT is a straightforward saxon:send-mail.

Runtime Error:

Code: Select all

java.lang.ClassNotFoundException: javax.mail.MessagingException
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at ro.sync.basic.classloader.LateDelegationClassLoader.loadClass(LateDelegationClassLoader.java:169)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.lang.Class.getConstructor0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at net.sf.saxon.functions.registry.BuiltInFunctionSet.makeFunction(BuiltInFunctionSet.java:225)
	at net.sf.saxon.functions.registry.BuiltInFunctionSet.bind(BuiltInFunctionSet.java:188)
	at net.sf.saxon.functions.FunctionLibraryList.bind(FunctionLibraryList.java:124)
	at net.sf.saxon.functions.FunctionLibraryList.bind(FunctionLibraryList.java:124)
	at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(XPathParser.java:3357)
	at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(XPathParser.java:2207)
	at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(XPathParser.java:2077)
	at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(XPathParser.java:1996)
	at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(XPathParser.java:1958)
	at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(XPathParser.java:1972)
	at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(XPathParser.java:1825)
	at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(XPathParser.java:754)
	at net.sf.saxon.expr.parser.XPathParser.parseExpression(XPathParser.java:661)
	at net.sf.saxon.expr.parser.XPathParser.parse(XPathParser.java:523)
	at net.sf.saxon.expr.parser.ExpressionTool.make(ExpressionTool.java:107)
	at net.sf.saxon.style.StyleElement.makeExpression(StyleElement.java:735)
	at net.sf.saxon.style.XSLValueOf.prepareAttributes(XSLValueOf.java:51)
	at net.sf.saxon.style.StyleElement.processAttributes(StyleElement.java:618)
	at net.sf.saxon.style.StyleElement.processAllAttributes(StyleElement.java:551)
	at net.sf.saxon.style.StyleElement.lambda$processAllAttributes$1(StyleElement.java:554)
	at net.sf.saxon.om.SequenceIterator.forEachOrFail(SequenceIterator.java:128)
	at net.sf.saxon.style.StyleElement.processAllAttributes(StyleElement.java:552)
	at net.sf.saxon.style.XSLTemplate.processAllAttributes(XSLTemplate.java:427)
	at net.sf.saxon.style.PrincipalStylesheetModule.processAllAttributes(PrincipalStylesheetModule.java:583)
	at net.sf.saxon.style.PrincipalStylesheetModule.preprocess(PrincipalStylesheetModule.java:367)
	at net.sf.saxon.style.Compilation.compilePackage(Compilation.java:287)
	at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:223)
	at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:107)
	at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:788)
	at net.sf.saxon.jaxp.SaxonTransformerFactory.newTemplates(SaxonTransformerFactory.java:168)
	at net.sf.saxon.jaxp.SaxonTransformerFactory.newTransformer(SaxonTransformerFactory.java:130)
	at ro.sync.xml.transformer.c.q(Unknown Source)
	at ro.sync.xml.transformer.c.w(Unknown Source)
	at ro.sync.xml.transformer.c.i(Unknown Source)
	at ro.sync.xml.transformer.c.ub(Unknown Source)
	at ro.sync.xml.transformer.c.jb(Unknown Source)
	at ro.sync.exml.editor.xmleditor.hc.doh(Unknown Source)
	at ro.sync.exml.editor.xmleditor.hc.eph(Unknown Source)
	at ro.sync.exml.editor.xmleditor.hc.boh(Unknown Source)
	at ro.sync.exml.editor.xmleditor.hc.zmh(Unknown Source)
	at ro.sync.exml.editor.xmleditor.hc.jnh(Unknown Source)
	at ro.sync.exml.editor.xmleditor.hc$4.kue(Unknown Source)
	at ro.sync.ui.application.lb.run(Unknown Source)
Scenario Extensions:
javamail scenario Extensions.jpg
javamail scenario Extensions.jpg (74.47 KiB) Viewed 745 times
XSLT Declaration:

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:saxon="http://saxon.sf.net/"
    exclude-result-prefixes="xs"
    version="3.0">
XSLT Context Reference:
https://www.saxonica.com/html/documenta ... -mail.html

What am I missing?

Thanks!

Re: XSLT javax.mail.MessagingException

Posted: Tue Mar 02, 2021 2:53 pm
by teo
Hello Fiona,

I investigated the issue you reported.
Indeed, it seems that the jars added as extensions in the transformation scenarios do not seem to be considered by Saxon.
Probably a class path problem.
I've added a new entry to our internal problem tracking tool to further investigate the issue.

In the meantime, as a workaround, you can try to copy the necessary jars to the oXygen lib folder.
I did so and the transformation succeeded.
I tested with version 1.6 of JavaMail API, downloaded from here: https://javaee.github.io/javamail.
That's for as Saxonica mentions on their website: "From Saxon 9.9, the required jar is compiled against version 1.6 (previously, this was version 1.4).".

Kind regards,
Teo

Re: XSLT javax.mail.MessagingException

Posted: Wed Mar 03, 2021 12:14 am
by Fiona Chen
Hello, Teo:

Thanks for getting back to me!

The transformation went through but I can't see such email.

Since yours succeeds, did you actually see the sent or received email? If yes, then what are the expected configurations?

What duds me is that I put a bogus email or password...etc, the transformation still happily happens ?


Best

Re: XSLT javax.mail.MessagingException

Posted: Thu Mar 04, 2021 3:51 pm
by teo
Hello, Fiona!

I admit that I also tested with fake email addresses.
My main goal was to determine the cause for the exception reported by you.
I'm not even sure I could overcome the security restrictions on my side so I could test with real email addresses.

Anyway, I don't have experience in using these Saxon mailing functions, but I could investigate further, if the problems persist on your side.
Seems to be a Saxon issue, however.

All the best,
Teo

Re: XSLT javax.mail.MessagingException

Posted: Fri Mar 05, 2021 12:14 am
by Fiona Chen
Hello, Teo:

My diagnosis process is deduced as such:
Problem Resolution and Goal - Problem Resolution.jpeg
Problem Resolution and Goal - Problem Resolution.jpeg (101.17 KiB) Viewed 604 times
I seldom move from one failed design to another. I would rather adapt and refine the idea until I find it untenable, then discard it and find the new solutions...

Best

Re: XSLT javax.mail.MessagingException

Posted: Fri Mar 05, 2021 3:27 pm
by teo
Hello, Fiona!

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs" xmlns:saxon="http://saxon.sf.net/"
    version="2.0">
    
    <xsl:template match="/">
        <xsl:variable name="mailSetup" select="map{'to':'RECIPIENT', 'from':'SENDER', 
            'smtp-server':'SMTP-SERVER', 'username':'USER', 'password':'PASS'}"/>
        <xsl:variable name="html">
            <html>
                <body>
                    <h1>Oxygen Email</h1>
                    <p>Test emailing from stylesheet...</p>
                </body>
            </html>
        </xsl:variable>
        
        <xsl:value-of select="saxon:send-mail($mailSetup, 'Test email' , $html, ())"/>
    </xsl:template>
    
</xsl:stylesheet>
I tested with the version 23.0 and the XSL from above.
Previously I put 'javax.mail-1.6.2.jar', 'mailapi-1.6.2.jar', and 'smtp-1.6.2.jar' in the Oxygen 'lib' folder (actually I used 'lib/endorsed').
You have to provide real values in 'mailSetup' variable from above and it should work.
All colleagues to whom I sent emails using the stylesheet above received them correctly according to the pattern declared in the 'html' variable.
Note that while testing and sending from my office account to my private gmail account, I had to check the Spam folder.
The stylesheet is built following the explanations from here: https://www.saxonica.com/html/documenta ... -mail.html.

Regards,
Teo

Re: XSLT javax.mail.MessagingException

Posted: Sat Mar 06, 2021 2:19 am
by Fiona Chen
Well done!
Just to tie up few loose ends:
[*] Given that Oxygen doesn’t honor JavaMail in the CLASSPATH or Extensions, the documentation of saxon:send-mail via Oxygen shall include:
    JavaMail release version
      Required collection of jar files and the version (mail, api, smtp, imap…etc)
        Installation and configuration specific (OS CLASSPATH and Oxygen path)

        [*] The send-mail function is persistently cached in Oxygen UI. More often than not, I have to exit the UI or remove the cache files in order to see the new config changes, causing the system inconsistent and fluctuate. This could be also due to the HTTP session not being released in the end.

        Best

        Re: XSLT javax.mail.MessagingException

        Posted: Mon Mar 08, 2021 7:06 pm
        by teo
        Hello, Fiona!

        I've added your latest comments to our issue created based on this thread, to be considered.
        If you could add more specific explanations regarding your remark about "send-mail function is persistently cached in Oxygen" it would be much appreciated and very helpful to our team.

        Regards,
        Teo

        Re: XSLT javax.mail.MessagingException

        Posted: Tue Mar 09, 2021 1:04 am
        by Fiona Chen
        Hello, Teo:

        Below was the testing result:
        Problem Resolution and Goal - send mail bug.jpeg
        Problem Resolution and Goal - send mail bug.jpeg (104.98 KiB) Viewed 489 times
        To put scenario1-4 into perspectives, the ramification (from the UI standpoint) is expanded as such:

        Transformation-A is completed and result is intended for:
        Recipient-A: Recipient-A@b.com
        Message: MTM valuation difference is found. Start reconciliation.

        Transformation-B is completed and result is intended for:
        Recipient-B: Recipient-B@d.com
        Message: strike had breached the knockout down. Start dispute.
        But the persistent session is still cached, transformation-B message was still sent to Recipient-A.

        The POSITIVE scenario is not within the purview of Oxygen or saxon:send-mail. I can turn on/off the backend security.

        Best