1

Hello all,
My application is based on PTV xServer modules and it is used of calculating best route and trip plan. It is a web application and I am using tomcat for it. So while running my application with tomcat it works find but when I executed this application with "main" method then I am getting error while calling xServer modules services/methods.

    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)  
Prakash Kumar
  • 29
  • 1
  • 6

1 Answers1

2

See CXF web service client: "Cannot create a secure XMLInputFactory"

The problem is that the application server classloader and local gives different priority to XML libraries

Solution 1 - Include CXF XML libraries (CXF2.7)

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

Solution 2 - Upgrade to CXF 3.0.0

Then woodstock is not needed

Solution 3 - Allow insecure parser Less secure

 add `-Dorg.apache.cxf.stax.allowInsecureParser=1` to the command line to execute your programa
Community
  • 1
  • 1
pedrofb
  • 37,271
  • 5
  • 94
  • 142