简体   繁体   English

当saxon xslt处理器抛出运行时错误时,如何防止Tomcat关闭?

[英]How to prevent Tomcat from shutting down when saxon xslt processor throws runtime errors?

I am using saxon to transform a .xhtml file in my web application. 我正在使用saxon转换Web应用程序中的.xhtml文件。 When saxon tries to transform a .xhtml document which is not well formed....it throws the following error :- 当saxon尝试转换格式不正确的.xhtml文档时....它将引发以下错误:-

Error on line 665 column 231 of Colruyt-Group-20190331-Annual-Filing.xhtml:
  SXXP0003: Error reported by XML parser: Element type "span" must be followed by either
  attribute specifications, ">" or "/>".
Recoverable error on line 62 of validateIXBRLXslt.xsl:
  SXXP0003: org.xml.sax.SAXParseException; systemId:
  file:/C:/Users/sasolkar/AppData/Local/Temp/bush_copied_files1700079536768843678/Colruyt-Group-20190331-Annual-Filing.xhtml; lineNumber: 665; columnNumber: 231; Element type "span" must be followed by either attribute specifications, ">" or "/>".
Error on line 62 of validateIXBRLXslt.xsl:
  FODC0002: Failed to load document
  file:/C:/Users/sasolkar/AppData/Local/Temp/bush_copied_files1700079536768843678/Colruyt-Group-20190331-Annual-Filing.xhtml
Transformation failed: Run-time errors were reported

and soon after tomcat server gets stopped.... Tomcat服务器停止后不久。

Aug 26, 2019 10:20:16 AM com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
INFO: Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir
Aug 26, 2019 10:20:30 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-apr-8080"]
Aug 26, 2019 10:20:30 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-apr-8009"]
Aug 26, 2019 10:20:30 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Aug 26, 2019 10:20:30 AM org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated for Servlet [default]
Aug 26, 2019 10:20:31 AM org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated for Servlet [default]
Aug 26, 2019 10:20:32 AM org.apache.catalina.core.StandardWrapper unload
INFO: Waiting for 1 instance(s) to be deallocated for Servlet [default]
Aug 26, 2019 10:20:32 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/bushchat-portal] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation.
Aug 26, 2019 10:20:32 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/bushchat-portal] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@5179827b]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@381bab5]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 26, 2019 10:20:32 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/bushchat-portal] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@5179827b]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@cb13461]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 26, 2019 10:20:32 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/bushchat-portal] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@4c2bf1fc]) and a value of type [org.apache.struts2.dispatcher.Dispatcher] (value [org.apache.struts2.dispatcher.Dispatcher@51dcc858]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 26, 2019 10:20:32 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/bushchat-portal] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@5f8694c4]) and a value of type [com.opensymphony.xwork2.ActionContext] (value [com.opensymphony.xwork2.ActionContext@5a91a169]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 26, 2019 10:20:32 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/bushchat-portal] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@49260fd6]) and a value of type [net.sf.saxon.expr.sort.LRUCache] (value [net.sf.saxon.expr.sort.LRUCache@7e8f80a2]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 26, 2019 10:20:32 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/bushchat-portal] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@5179827b]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@15440b03]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Aug 26, 2019 10:20:32 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-apr-8080"]
Aug 26, 2019 10:20:37 AM org.apache.tomcat.util.net.AbstractEndpoint shutdownExecutor
WARNING: The executor associated with thread pool [http-apr-8080] has not fully shutdown. Some application threads may still be running.
Aug 26, 2019 10:20:37 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-apr-8009"]
Aug 26, 2019 10:20:38 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-apr-8080"]
Aug 26, 2019 10:20:38 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-apr-8009"]

I tried to catch the errors by surrounding the transformation statements with catch block as follows....but it doesn't seem to work.... 我试图通过将转换语句用catch块括起来来捕获错误,如下所示。但是它似乎不起作用。

  try {
            .
            .
            .
            .

            String[] args  = new String[7];
            args[0] = "-xsl:"+xsltPath;
            args[1] = "-o:"+outputPath;
            args[2] = "-it:main";
            args[3] = "delimiter="+delimiter;
            args[4] = "errPropPath="+errPropPath; 
            args[5] = "xsltFolderPath="+xsltFolderPath; 
            args[6] = "inputfiles="+inputPath+"";

            //SAXON gets called over here...
            Transform.main(args);

            .
            .
            .
            .

        } catch (Exception e1) {
            logger.debug("exception",e1);
        }catch(Error e ){
            logger.debug("error",e);
        }

You are invoking the transformation using the command line interface: 您正在使用命令行界面调用转换:

Transform.main(args);

By default this closes the Java VM (using quit()) when a dynamic error occurs in the transformation. 默认情况下,当转换中发生动态错误时,这将关闭Java VM(使用quit())。 There is an option -quit:off to change this behaviour. 有一个-quit:off选项可以更改此行为。

However, this is not the recommended way to invoke Saxon from a Java application. 但是,这不是从Java应用程序中调用Saxon的推荐方法。 The recommended ways are to use either the JAXP API or the s9api API. 推荐的方法是使用JAXP API或s9api API。 Both are documented at http://www.saxonica.com/documentation/index.html#!using-xsl/embedding 两者都记录在http://www.saxonica.com/documentation/index.html#!using-xsl/embedding

Using an API gives you far more control over the way the transformation runs. 使用API​​可让您更好地控制转换的运行方式。 For starters, if you use the same stylesheet once to transform multiple documents, it allows you to compile the stylesheet once and use it repeatedly. 对于初学者,如果一次使用同一样式表来转换多个文档,则它可以一次编译一次样式表并重复使用。 This is important because compiling the stylesheet often dominates the transformation time. 这很重要,因为编译样式表通常会占用转换时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM