获得“ http://javax.xml.xmlconstants/property/accessexternaldtd属性不支持”在Jboss并使用Springboot

发布于 2025-01-28 03:03:19 字数 658 浏览 5 评论 0原文

在将应用程序升级为Spring Boot 2.6.6与JBOSS 7.3结合使用后,我们对每个XML验证进行了以下警告:

2022-04-13 14:18:39,433 WARN  [org.springframework.xml.validation.Jaxp15ValidatorFactory] (default task-2) http://javax.xml.XMLConstants/property/accessExternalDTD property not supported by org.apache.xerces.jaxp.validation.ValidatorImpl
2022-04-13 14:18:39,433 WARN  [org.springframework.xml.validation.Jaxp15ValidatorFactory] (default task-1) http://javax.xml.XMLConstants/property/accessExternalSchema property not supported by org.apache.xerces.jaxp.validation.ValidatorImpl

由于大量验证量,JBOSS磁盘被填充了日志警告,导致完整磁盘。

最明显的解决方案是不使用JBOSS,但不幸的是,这在我们的生产环境中是不可能的。

After upgrading our application to spring boot 2.6.6 in combination with JBoss 7.3 we get on every xml validation the following warnings:

2022-04-13 14:18:39,433 WARN  [org.springframework.xml.validation.Jaxp15ValidatorFactory] (default task-2) http://javax.xml.XMLConstants/property/accessExternalDTD property not supported by org.apache.xerces.jaxp.validation.ValidatorImpl
2022-04-13 14:18:39,433 WARN  [org.springframework.xml.validation.Jaxp15ValidatorFactory] (default task-1) http://javax.xml.XMLConstants/property/accessExternalSchema property not supported by org.apache.xerces.jaxp.validation.ValidatorImpl

Due to the intensive number of validations, the JBoss disk was filled with a log warnings resulting in a full disk.

The most obvious solution is not to use JBoss, but unfortunately that is not possible in our production environment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清风疏影 2025-02-04 03:03:19

警告的原因是JBOSS 7.3使用不支持属性的旧Xerces库(2.2.12.0.sp03):AccessExternalDTD和AccessExternalDTD和AccessExternalSshema and Spring-boot(2.6.6)期望支持此功能并在何时登录警告。不支持。

通常,您应该更新到Xerces库的较新版本,但是在JBoss的情况下,这是不可能的,因为Xerces库与JBOSS打包。

这样做的解决方案是将JBOSS中的日志记录设置更改为此特定日志记录的错误级别。这可以通过以下命令来完成:

${JBOSS_HOME}/bin/jboss-cli.sh --connect controller=localhost:9990 --user=<admin user> --password=<password> --command="/subsystem=logging/logger=org.springframework.xml.validation.Jaxp15ValidatorFactory:add"
${JBOSS_HOME}/bin/jboss-cli.sh --connect controller=localhost:9990 --user=<admin user> --password=<password> --command="/subsystem=logging/logger=org.springframework.xml.validation.Jaxp15ValidatorFactory:write-attribute(name=level, value=ERROR)"

The reason for the warning is that JBoss 7.3 is using an old Xerces library (2.2.12.0.SP03) which does not support the properties: accessExternalDTD and accessExternalSchema and spring-boot (2.6.6) expect support for this and log a warning when it is not supported.

Normally you should update to a newer version of the Xerces library but in the case of JBoss this is not possible because the Xerces library is packaged with JBoss.

The solution for this is to change the logging settings in JBoss to the error level for this particular logging. This can be done with the following commands:

${JBOSS_HOME}/bin/jboss-cli.sh --connect controller=localhost:9990 --user=<admin user> --password=<password> --command="/subsystem=logging/logger=org.springframework.xml.validation.Jaxp15ValidatorFactory:add"
${JBOSS_HOME}/bin/jboss-cli.sh --connect controller=localhost:9990 --user=<admin user> --password=<password> --command="/subsystem=logging/logger=org.springframework.xml.validation.Jaxp15ValidatorFactory:write-attribute(name=level, value=ERROR)"
巷子口的你 2025-02-04 03:03:19

添加xmlparserv2依赖项之后遇到了同样的问题,因为突然间,classLoader开始加载oracle.xml.jaxp.jxsaxsaxtransformerfactory不支持accept> accessects Excessexternaldtdtd /code>,而不是像以前那样服用transformerfactoryimpl

发生这种情况是因为现在出现了javax.xml.transform.transformerfactory的其他实现,而classloader正在加载错误的

解决方案是明确告诉ClassLoader要加载哪个类:

TransformerFactory tf = TransformerFactory.newInstance(
    "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
    this.getClass().getClassLoader()
);
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
Transformer transformer = tf.newTransformer();

或将其设置为JVM参数

-Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

Had the same issue after adding xmlparserv2 dependency, because all of a sudden the ClassLoader started loading the oracle.xml.jaxp.JXSAXTransformerFactory which doesn't support accessExternalDTD, instead of taking the TransformerFactoryImpl like it used to.

This happened because now there appeared an additional implementation of the javax.xml.transform.TransformerFactory and classloader was loading the wrong one.

Solution was to explicitly tell ClassLoader which class to load:

TransformerFactory tf = TransformerFactory.newInstance(
    "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
    this.getClass().getClassLoader()
);
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
Transformer transformer = tf.newTransformer();

or alternatively set it as JVM argument with

-Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
月下客 2025-02-04 03:03:19

提供的validatorFactory的实现不支持上述属性。

正如@gerard的答案中提到的,jboss org.apache.xerces依赖关系提供了其实现。

您可以配置程序以使用支持或忽略上述属性的实现。

我在另一个

The provided implementation of the ValidatorFactory doesn't support the mentioned property.

As it's mentioned in the answer of @Gerard, JBoss org.apache.xerces dependency provides its implementation.

You can configure your program to use the implementation that supports or ignores the mentioned property.

I elaborated on the details in another similar answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文