XSLT javax.mail.MessagingException

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Fiona Chen
Posts: 17
Joined: Fri Aug 21, 2020 5:40 pm

XSLT javax.mail.MessagingException

Post 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 2240 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!
teo
Posts: 57
Joined: Wed Aug 30, 2017 3:56 pm

Re: XSLT javax.mail.MessagingException

Post 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
Teodor Timplaru
<oXygen/> XML Editor
http://www.oxygenxml.com
Fiona Chen
Posts: 17
Joined: Fri Aug 21, 2020 5:40 pm

Re: XSLT javax.mail.MessagingException

Post 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
teo
Posts: 57
Joined: Wed Aug 30, 2017 3:56 pm

Re: XSLT javax.mail.MessagingException

Post 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
Teodor Timplaru
<oXygen/> XML Editor
http://www.oxygenxml.com
Fiona Chen
Posts: 17
Joined: Fri Aug 21, 2020 5:40 pm

Re: XSLT javax.mail.MessagingException

Post 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 2099 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
teo
Posts: 57
Joined: Wed Aug 30, 2017 3:56 pm

Re: XSLT javax.mail.MessagingException

Post 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
Teodor Timplaru
<oXygen/> XML Editor
http://www.oxygenxml.com
Fiona Chen
Posts: 17
Joined: Fri Aug 21, 2020 5:40 pm

Re: XSLT javax.mail.MessagingException

Post 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
        teo
        Posts: 57
        Joined: Wed Aug 30, 2017 3:56 pm

        Re: XSLT javax.mail.MessagingException

        Post 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
        Teodor Timplaru
        <oXygen/> XML Editor
        http://www.oxygenxml.com
        Fiona Chen
        Posts: 17
        Joined: Fri Aug 21, 2020 5:40 pm

        Re: XSLT javax.mail.MessagingException

        Post 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 1984 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
        Post Reply