org.springframework.ws and Xalan problem on Jboss EAP 6.x

可紊 提交于 2019-12-11 17:28:36

问题


Hello I'm facing problem with Jboss EAP 6.x after update org.springframework.ws - spring-xml

In my project I have use Xalan in version 2.7.2 , now I want to update org.springframework.ws - spring-xml from version 2.4.0 to 2.4.4 and upload wars of my app on Jboss EAP 6.x

While deployment I got error:

Caused by: java.lang.IllegalArgumentException: Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD at org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:571) at __redirected.__TransformerFactory.setAttribute(__TransformerFactory.java:169) [jboss-modules.jar:1.3.5.Final-redhat-1] at org.springframework.xml.transform.TransformerFactoryUtils.defaultSettings(TransformerFactoryUtils.java:56) [spring-xml-2.4.4.RELEASE.jar:] at org.springframework.xml.transform.TransformerFactoryUtils.newInstance(TransformerFactoryUtils.java:32) [spring-xml-2.4.4.RELEASE.jar:] at org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping.(PayloadRootAnnotationMethodEndpointMapping.java:58) [spring-ws-core-2.4.4.RELEASE.jar:] ... 31 more

After fast investigation I have found that in spring-xml version 2.4.4 it's new TransformerFactoryUtils which uses TransformerFactory from same package as Xalan , and it's leads to problem with classloader.

I try to follow solutions from TransformerFactory and Xalan Dependency Conflict and xalan and xerces in jboss eap 6.0.1 but both won't work for me.

I have also found some solution on redhat site : https://access.redhat.com/solutions/1410603 but without subscription I don't have access for it...

And one face same issue? Maybe have some solution which may work in this case? Big thanks in advance.


回答1:


I have the same issue even for JBoss EAP 7.2

Since JBoss runs on JDK 6, 7, and 8, that is why the included Xalan does not have ACCESS_EXTERNAL_DTD support as it was added in JDK 7.

You may force JBoss to use TransformerFactory from Oracle JDK 8. Set the variable transformerFactoryClass to com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl. See the snapshot below.

final Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

final WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
webServiceTemplate.setDefaultUri(uri);
webServiceTemplate.setMarshaller(marshaller);
webServiceTemplate.setUnmarshaller(marshaller);

try {
    logger.debug("Getting class for name: {}", transformerFactoryClass);
    final Class<?> clazz = Class.forName(transformerFactoryClass);
    Assert.isAssignable(TransformerFactory.class, clazz, "Must be instance of Class<? extends TransformerFactory>");
    webServiceTemplate.setTransformerFactoryClass((Class<? extends TransformerFactory>) clazz);
} catch (ClassNotFoundException e) {
    logger.error("Unable to get class for name: {}", transformerFactoryClass);
    throw new IllegalArgumentException(e);
}


来源:https://stackoverflow.com/questions/54822957/org-springframework-ws-and-xalan-problem-on-jboss-eap-6-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!