enonic / lib-xslt

XSLT library for Enonic XP.
Apache License 2.0
0 stars 2 forks source link

Improved logging/debugging #2

Closed Bellfalasch closed 5 years ago

Bellfalasch commented 6 years ago

When something crashes in the XSLT rendering, it is not possible to see which line in the XSLT that caused it, or why. Could this info be passed into the logs? That would improve debugging in the RSS app since it relies on pretty complex setups and mappings and needs to be debugged often. Bouvet and others also have problems with this.

aro commented 6 years ago

@Bellfalasch Can I get some examples of XSLT errors to test?

Bellfalasch commented 6 years ago

Sure @aro - Easiest is to start by cloning the code for app-rss on our Github, with it you have a semi-complex XSLT that is very prone to crashing if the data sent in is wrong compared to the xpath's (to my understanding).

After that, use this Content Type to connect to. I think the problem is that the XSLT expects one line of data for Author, but it gets multiple. But just guessing here since customer didn't see any error messages.

<content-type>
<display-name>Blog - Classic</display-name>
<super-type>base:structured</super-type>
<form>
<input name="image" type="ImageSelector">
<label>Main image</label>
<config>
<allowPath>${site}/*</allowPath>
</config>
</input>
<input name="cinemagraphics" type="ImageSelector">
<label>Cinemagraphics</label>
<config>
<allowPath>${site}/*</allowPath>
</config>
</input>
<input name="authors" type="ContentSelector">
<label>Authors</label>
<occurrences minimum="0" maximum="0"/>
<config>
<relationship-type>system:reference</relationship-type>
<allow-content-type>person</allow-content-type>
<allowPath>${site}/*</allowPath>
</config>
</input>
<input name="heading" type="TextLine">
<label>Heading</label>
<occurrences minimum="1" maximum="1"/>
</input>
<input name="lead" type="TextArea">
<label>Lead text</label>
</input>
<input name="body" type="HtmlArea">
<label>Body text</label>
</input>
<field-set name="meta">
<label>Info fra den gamle bloggen</label>
<items>
<input name="oldLink" type="TextLine">
<label>Gammel Link</label>
<help-text>F.eks https://enonic.com</help-text>
</input>
<input name="oldDate" type="DateTime">
<label>Gammel publiseringsdato/tid YYYY-MM-DD tt:mm</label>
</input>
</items>
</field-set>
</form>
</content-type>

According to readme/docs to RSS App you need to setup some things. A Page Template using the page controller the app ships with, and creating a RSS content with the following config. You can skip exclude and include path config:

ld4qc7pmedw00dozfcahwhsbt

So far all errors have been a matter of trial and error to fix.

This feature request comes from ticket #2276 in our support.

Bellfalasch commented 6 years ago

The error in the log looks to me like this: Very hard to know what is wrong. I know some data (or my XSLT) is wrong, but what part?

java.lang.RuntimeException: javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
    at com.google.common.base.Throwables.propagate(Throwables.java:160)
    at com.enonic.lib.xslt.XsltProcessor.handleError(XsltProcessor.java:114)
    at com.enonic.lib.xslt.XsltProcessor.handleError(XsltProcessor.java:88)
    at com.enonic.lib.xslt.XsltProcessor.process(XsltProcessor.java:80)
    at jdk.nashorn.internal.scripts.Script$Recompilation$1323$596AA$xslt.L:1#render(com.enonic.app.rss:/lib/xslt.js:25)
    at jdk.nashorn.internal.scripts.Script$Recompilation$1200$2092A$rss.L:1#get(com.enonic.app.rss:/site/pages/rss/rss.js:275)
    at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:639)
    at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
    at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
    at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117)
    at com.enonic.xp.script.impl.value.FunctionScriptValue.call(FunctionScriptValue.java:36)
    at com.enonic.xp.script.impl.executor.ScriptExportsImpl.executeMethod(ScriptExportsImpl.java:56)
    at com.enonic.xp.portal.impl.controller.ControllerScriptImpl.doExecute(ControllerScriptImpl.java:71)
    at com.enonic.xp.portal.impl.controller.ControllerScriptImpl.lambda$execute$0(ControllerScriptImpl.java:36)
    at com.enonic.xp.trace.Tracer.traceEx(Tracer.java:72)
    at com.enonic.xp.trace.Tracer.trace(Tracer.java:51)
    at com.enonic.xp.trace.Tracer.trace(Tracer.java:98)
    at com.enonic.xp.portal.impl.controller.ControllerScriptImpl.execute(ControllerScriptImpl.java:36)
    at com.enonic.xp.portal.impl.rendering.PageRenderer.doRender(PageRenderer.java:48)
    at com.enonic.xp.portal.impl.rendering.PageRenderer.doRender(PageRenderer.java:27)
    at com.enonic.xp.portal.impl.rendering.PostProcessingRenderer.render(PostProcessingRenderer.java:25)
    at com.enonic.xp.portal.impl.handler.render.PageHandlerWorker.execute(PageHandlerWorker.java:128)
    at com.enonic.xp.portal.impl.handler.render.PageHandler.doHandle(PageHandler.java:62)
    at com.enonic.xp.portal.impl.handler.render.PageHandler.doHandle(PageHandler.java:22)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:71)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:75)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.portal.handler.BasePortalHandler.doHandle(BasePortalHandler.java:48)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:71)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.impl.trace.TraceWebFilter.doHandle(TraceWebFilter.java:37)
    at com.enonic.xp.web.handler.BaseWebHandler.handle(BaseWebHandler.java:71)
    at com.enonic.xp.web.impl.handler.WebHandlerChainImpl.handle(WebHandlerChainImpl.java:30)
    at com.enonic.xp.web.impl.handler.WebDispatcherImpl.dispatch(WebDispatcherImpl.java:50)
    at com.enonic.xp.web.impl.handler.WebDispatcherServlet.doHandle(WebDispatcherServlet.java:135)
    at com.enonic.xp.web.impl.handler.WebDispatcherServlet.service(WebDispatcherServlet.java:63)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at com.enonic.xp.web.impl.dispatch.mapping.ServletDefinitionImpl.service(ServletDefinitionImpl.java:39)
    at com.enonic.xp.web.impl.dispatch.pipeline.ServletPipelineImpl.service(ServletPipelineImpl.java:30)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:45)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:36)
    at com.enonic.xp.portal.impl.auth.AuthFilter.doHandle(AuthFilter.java:45)
    at com.enonic.xp.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:31)
    at com.enonic.xp.web.filter.BaseWebFilter.doFilter(BaseWebFilter.java:33)
    at com.enonic.xp.web.impl.dispatch.mapping.FilterDefinitionImpl.doFilter(FilterDefinitionImpl.java:40)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:50)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:36)
    at com.enonic.xp.web.impl.auth.BasicAuthFilter.doHandle(BasicAuthFilter.java:33)
    at com.enonic.xp.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:31)
    at com.enonic.xp.web.filter.BaseWebFilter.doFilter(BaseWebFilter.java:33)
    at com.enonic.xp.web.impl.dispatch.mapping.FilterDefinitionImpl.doFilter(FilterDefinitionImpl.java:40)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:50)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:36)
    at com.enonic.xp.web.impl.context.ContextFilter.lambda$doHandle$0(ContextFilter.java:33)
    at com.enonic.xp.context.ContextImpl.callWith(ContextImpl.java:101)
    at com.enonic.xp.web.impl.context.ContextFilter.doHandle(ContextFilter.java:32)
    at com.enonic.xp.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:31)
    at com.enonic.xp.web.filter.BaseWebFilter.doFilter(BaseWebFilter.java:33)
    at com.enonic.xp.web.impl.dispatch.mapping.FilterDefinitionImpl.doFilter(FilterDefinitionImpl.java:40)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:50)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:36)
    at com.enonic.xp.web.vhost.impl.VirtualHostFilter.doHandle(VirtualHostFilter.java:57)
    at com.enonic.xp.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:31)
    at com.enonic.xp.web.filter.BaseWebFilter.doFilter(BaseWebFilter.java:33)
    at com.enonic.xp.web.impl.dispatch.mapping.FilterDefinitionImpl.doFilter(FilterDefinitionImpl.java:40)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:50)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:36)
    at com.enonic.xp.web.impl.dos.DosFilterWrapper.doFilter(DosFilterWrapper.java:64)
    at com.enonic.xp.web.impl.dispatch.mapping.FilterDefinitionImpl.doFilter(FilterDefinitionImpl.java:40)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:50)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterChainImpl.doFilter(FilterChainImpl.java:36)
    at com.enonic.xp.web.impl.dispatch.pipeline.FilterPipelineImpl.filter(FilterPipelineImpl.java:29)
    at com.enonic.xp.web.impl.dispatch.DispatchServletImpl.service(DispatchServletImpl.java:35)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:437)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
    at com.codahale.metrics.jetty9.InstrumentedHandler.handle(InstrumentedHandler.java:240)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
    at org.eclipse.jetty.server.Server.handle(Server.java:517)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
    at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
    at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
    at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:249)
    at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:142)
    at net.sf.saxon.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:97)
    at com.enonic.lib.xslt.XsltProcessor.createTransformer(XsltProcessor.java:153)
    at com.enonic.lib.xslt.XsltProcessor.doProcess(XsltProcessor.java:132)
    at com.enonic.lib.xslt.XsltProcessor.process(XsltProcessor.java:71)
    ... 115 more
Bellfalasch commented 5 years ago

Could we get this done before you leave? Just some more output in the logs when the XSLT is wrong ... or perhaps this is done? @aro