Неизвестный атрибут accessExternalDTD при создании bean-компонента Spring - PullRequest
0 голосов
/ 21 января 2019

Я унаследовал старое (15 лет) Java-приложение, которое поддерживалось плохо.Mavenizing не был выполнен должным образом, поэтому я попробовал его, поскольку многие библиотеки были добавлены в classpath вручную.Теперь у меня есть мастер-pom, в котором все файлы находятся в зависимости как файл pom.

Ошибка выглядит следующим образом:

Ошибка вызова метода init;вложенным исключением является java.lang.IllegalArgumentException: неизвестный атрибут http://javax.xml.XMLConstants/property/accessExternalDTD

Но теперь у меня возникают некоторые проблемы с синтаксическим анализатором при запуске моих веб-сервисов.Старый проект использует SaxParser для XML, но также использует Spring, где я вижу конфликты при инициализации bean-компонентов.

Я уже обновился до Java 8 (работает также на Liberty Profile, так как мы связаны с IBM с IBMJDK 8).Добавлен jaxp-api для получения атрибута accessExternalDTD на пути к классам.Удалена реализация xerces (также исключена из зависимостей xalan), но ничего не сработало.

[err] JAXP: find factoryId=javax.xml.parsers.DocumentBuilderFactory
[err] JAXP: found service provider by ServiceLoader, value=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
2019-01-21 11:18:35 DEBUG CalculationExecutor:186 -    0.000 CalculationExecutor.new: begin

2019-01-21 11:18:35 DEBUG Loader:50 - Trying to find [project-calculationKernel.xml] using context classloader: com.ibm.ws.classloading.internal.ThreadContextClassLoader@c5d35d81.

2019-01-21 11:18:35 DEBUG Loader:56 - Found: wsjar:file:/C:/LogFiles/Tools/wlp-webProfile8-java8-win-x86_64-18.0.0.4/wlp/usr/servers/Server18.0.0.4/apps/expanded/CreditRiskWebServicesEAR.ear/CreditRiskWebServices.war/WEB-INF/lib/RiskRatingCalculation-17.0.48-SNAPSHOT.jar!/project-calculationKernel.xml

2019-01-21 11:18:35 INFO  BaseCastorMappingMarshaller:33 - Castor version used by Castor Mapping Marshaller: 1.2  [0]

2019-01-21 11:18:35 DEBUG Loader:50 - Trying to find [castorMapping-projectConfiguration.xml] using context classloader: com.ibm.ws.classloading.internal.ThreadContextClassLoader@c5d35d81.

2019-01-21 11:18:35 DEBUG Loader:56 - Found: wsjar:file:/C:/LogFiles/Tools/wlp-webProfile8-java8-win-x86_64-18.0.0.4/wlp/usr/servers/Server18.0.0.4/apps/expanded/CreditRiskWebServicesEAR.ear/CreditRiskWebServices.war/WEB-INF/lib/CalculationKernelSE-17.0.48-SNAPSHOT.jar!/castorMapping-projectConfiguration.xml

[err] JAXP: find factoryId=javax.xml.parsers.SAXParserFactory
[err] JAXP: found service provider by ServiceLoader, value=org.apache.xerces.jaxp.SAXParserFactoryImpl
[err] JAXP: find factoryId=javax.xml.parsers.SAXParserFactory
[err] JAXP: found service provider by ServiceLoader, value=org.apache.xerces.jaxp.SAXParserFactoryImpl
2019-01-21 11:18:35 DEBUG CalculationExecutor:186 -    0.00691 CalculationExecutor.new: end

[err] JAXP: find factoryId=javax.xml.parsers.DocumentBuilderFactory
[err] JAXP: found service provider by ServiceLoader, value=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
[err] JAXP: find factoryId=javax.xml.transform.TransformerFactory
[err] Warning: external object model net.sf.saxon.dom.DOMEnvelope has been loaded, but is not an instance of net.sf.saxon.om.ExternalObjectModel
[err] Warning: external object model net.sf.saxon.dom.DOMObjectModel has been loaded, but is not an instance of net.sf.saxon.om.ExternalObjectModel
[err] JAXP: found service provider by ServiceLoader, value=net.sf.saxon.TransformerFactoryImpl
[ERROR   ] SRVE0283E: Exception caught while initializing context: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'soapRiskApprovalService' defined in ServletContext resource [/WEB-INF/applicationContext-creditRiskWebServices.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Unknown attribute http://javax.xml.XMLConstants/property/accessExternalDTD
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$136.00000000124ED300.getObject(Unknown Source)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:400)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
    at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2376)
    at [internal classes]
Caused by: java.lang.IllegalArgumentException: Unknown attribute http://javax.xml.XMLConstants/property/accessExternalDTD
    at net.sf.saxon.Configuration.setConfigurationProperty(Configuration.java:2185)
    at net.sf.saxon.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:342)
    at org.springframework.xml.transform.TransformerFactoryUtils.defaultSettings(TransformerFactoryUtils.java:56)
    at org.springframework.xml.transform.TransformerFactoryUtils.newInstance(TransformerFactoryUtils.java:32)
    at org.springframework.xml.transform.TransformerHelper.newTransformerFactory(TransformerHelper.java:88)
    at org.springframework.xml.transform.TransformerHelper.getTransformerFactory(TransformerHelper.java:104)
    at org.springframework.xml.transform.TransformerHelper.createTransformer(TransformerHelper.java:119)
    at org.springframework.xml.transform.TransformerHelper.transform(TransformerHelper.java:131)
    at org.springframework.xml.transform.TransformerObjectSupport.transform(TransformerObjectSupport.java:96)
    at org.springframework.ws.wsdl.wsdl11.provider.InliningXsdSchemaTypesProvider.getSchemaElement(InliningXsdSchemaTypesProvider.java:113)
    at org.springframework.ws.wsdl.wsdl11.provider.InliningXsdSchemaTypesProvider.addTypes(InliningXsdSchemaTypesProvider.java:101)
    at org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition.afterPropertiesSet(ProviderBasedWsdl4jDefinition.java:234)
    at org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition.afterPropertiesSet(DefaultWsdl11Definition.java:183)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741)
    ... 15 more

Я много гуглил, но не смог найти никакого подхода, который заставил бы запустить это старое приложение.Надеюсь, что кто-то сталкивался с такими же проблемами и может указать мне, как с этим справиться.

Ответы [ 2 ]

0 голосов
/ 22 марта 2019

Попробуйте настроить TransformerFactory из JDK 8. Здесь есть проблема в JBoss, но снимок кода должен работать так же https://stackoverflow.com/a/55304023/204950

0 голосов
/ 19 февраля 2019

Ваша проблема, похоже, связана с SWS-1049 , она была представлена ​​в spring-ws 3.0.6.RELEASE. вам нужно использовать 3.0.7.BUILD-SNAPSHOT.

...