gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 22:46:45 24 4
gpt4 key购买 nike

我正在使用 saxon 转换我的网络应用程序中的 .xhtml 文件。当 saxon 尝试转换格式不正确的 .xhtml 文档时....它会抛出以下错误:-

Error on line 665 column 231 of ABXDE123nual-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 someXSLT.xsl:
SXXP0003: org.xml.sax.SAXParseException; systemId:
file:/C:/Users/ruowier/AppData/Local/Temp/temp1231700079536768843678/ABXDE123nual-Filing.xhtml; lineNumber: 665; columnNumber: 231; Element type "span" must be followed by either attribute specifications, ">" or "/>".
Error on line 62 of someXSLT.xsl:
FODC0002: Failed to load document
file:/C:/Users/ruowier/AppData/Local/Temp/temp1231700079536768843678/ABXDE123nual-Filing.xhtml
Transformation failed: Run-time errors were reported

在 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 [/somePortal] 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 [/somePortal] 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 [/somePortal] 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 [/somePortal] 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 [/somePortal] 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 [/somePortal] 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 [/somePortal] 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"]

我试图通过如下方式用 catch block 包围转换语句来捕获错误....但它似乎不起作用....

  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);
}

最佳答案

您正在使用命令行界面调用转换:

Transform.main(args);

默认情况下,当转换中发生动态错误时,这将关闭 Java VM(使用 quit())。有一个选项 -quit:off 可以改变这种行为。

但是,这不是从 Java 应用程序调用 Saxon 的推荐方法。推荐的方法是使用 JAXP API 或 s9api API。两者都记录在 http://www.saxonica.com/documentation/index.html#!using-xsl/embedding

使用 API 可以让您更好地控制转换的运行方式。对于初学者来说,如果您使用同一个样式表一次来转换多个文档,它允许您编译一次样式表并重复使用它。这很重要,因为编译样式表通常会占用转换时间。

关于java - 当 saxon xslt 处理器抛出运行时错误时,如何防止 Tomcat 关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57651839/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com