gpt4 book ai didi

java - 无法创建安全的 XMLInputFactory

转载 作者:行者123 更新时间:2023-11-28 22:17:50 25 4
gpt4 key购买 nike

大家好,
我的应用程序基于 PTV xServer 模块,用于计算最佳路线和行程计划。 这是一个 web 应用程序,我正在为它使用 tomcat。 因此,在使用 tomcat 运行我的应用程序时,它可以找到,但是当我使用“main”方法执行该应用程序时,调用 xServer 模块服务/方法时出现错误。

    com.ptvag.jabba.core.exception.UnexpectedException: Cannot create a secure XMLInputFactory
at com.ptvag.jabba.core.exception.ExceptionAnalyzer.mapExternalException(ExceptionAnalyzer.java:43)
at com.ptvag.xserver.xlocate.XLocateCXFClient.findLocation(Unknown Source)
at com.ilume.ptv.adapter.xmodule.XLocateAdapter.findLocations(XLocateAdapter.java:278)
at com.ilume.ptv.adapter.xmodule.XLocateAdapter.findLocations(XLocateAdapter.java:248)
at com.ilume.jti.logic.controller.models.rerouting.DepotsBO.isDepotValid(DepotsBO.java:182)
at com.ilume.jti.logic.controller.models.rerouting.DepotsBO.<init>(DepotsBO.java:96)
at com.ilume.jti.service.mapper.ReRouteMapper.mapJaxbJavaToBO(ReRouteMapper.java:155)
at com.ilume.jti.service.mapper.ReRouteMapper.mapJaxbJavaToBO(ReRouteMapper.java:134)
at com.ilume.jti.test.help.InputHelper.getCycleFromXMLResource(InputHelper.java:78)
at com.ilume.jti.test.controller.russia.RussiaReRoutingControllerTest.getCycle(RussiaReRoutingControllerTest.java:58)
at com.ilume.jti.test.controller.russia.RussiaReRoutingControllerTest.testTestReRouting(RussiaReRoutingControllerTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
at org.apache.cxf.staxutils.StaxUtils.createXMLInputFactory(StaxUtils.java:314)
at org.apache.cxf.staxutils.StaxUtils.getXMLInputFactory(StaxUtils.java:264)
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1516)
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1415)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:247)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:206)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:101)
at javax.xml.ws.Service.<init>(Service.java:77)
at com.ptvag.xserver.xlocate.jwsdp.XLocateWSService.<init>(Unknown Source)
at com.ptvag.xserver.xlocate.XLocateCXFClient.getWebService(Unknown Source)

最佳答案

参见 CXF web service client: "Cannot create a secure XMLInputFactory"

问题是应用服务器类加载器和本地给XML库不同的优先级

解决方案 1 - 包含 CXF XML 库 (CXF2.7)

Add stax2-api and woodstox-core-asl jars from the 2.7.x CXF distribution 

解决方案 2 - 升级到 CXF 3.0.0

Then woodstock is not needed

解决方案 3 - 允许不安全的解析器不太安全

 add `-Dorg.apache.cxf.stax.allowInsecureParser=1` to the command line to execute your programa

关于java - 无法创建安全的 XMLInputFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37590793/

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