salesforce-marketingcloud / FuelSDK-Java

Salesforce Marketing Cloud Java SDK
BSD 3-Clause "New" or "Revised" License
73 stars 122 forks source link

Tomcat 8 Failed to create service #19

Closed AndrewJMiller closed 4 years ago

AndrewJMiller commented 9 years ago

I'm getting the following exception on my server when setting up an ETClient. Local on my Mac (java 8, tomcat 8) it runs fine. The server is Ubuntu running Java 8 and Tomcat 8. Any help would be appreciated.

java version "1.8.0_05"

DISTRIB_ID=Ubuntu DISTRIB_RELEASE=12.04 DISTRIB_CODENAME=precise DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS" NAME="Ubuntu" VERSION="12.04.5 LTS, Precise Pangolin" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu precise (12.04.5 LTS)" VERSION_ID="12.04"

Tomcat Version : Apache Tomcat/8.0.9 Servlet Specification Version : 3.1 JSP version : 2.3

ETClientTest.java
102. ETClient client;
103. try {
104.        client = new ETClient(config);

 javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
    at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:98)
    at javax.xml.ws.Service.<init>(Service.java:77)
    at com.exacttarget.fuelsdk.internal.PartnerAPI.<init>(PartnerAPI.java:49)
    at com.exacttarget.fuelsdk.ETSoapConnection.<init>(ETSoapConnection.java:78)
    at com.exacttarget.fuelsdk.ETClient.<init>(ETClient.java:134)
    at ETClientTest.java:104)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:100)
    at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:199)
    at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
    ... 14 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:256)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:205)
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
    ... 16 more
Caused by: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
    at org.apache.cxf.staxutils.StaxUtils.createXMLInputFactory(StaxUtils.java:300)
    at org.apache.cxf.staxutils.StaxUtils.getXMLInputFactory(StaxUtils.java:255)
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1416)
    at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1318)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:246)
    ... 18 more
vtekum commented 8 years ago

Hi.. How did you resolve this issue? I am getting the same error. It works fine on windows, but fails on linux. Thanks for your help.

AndrewJMiller commented 8 years ago

One temporary workaround we've found is to allow insecure parsing, but you'll want to be careful changing that setting as it's could open up your system to a DOS vulnerability. http://cxf.apache.org/security-advisories.data/CVE-2013-2160.txt.asc?version=1&modificationDate=1372324301000&api=v2

In java_options and add -Dorg.apache.cxf.stax.allowInsecureParser=1

We would love a fix or a more secure solution.

righettime commented 6 years ago

Is there an update for this issue? I'm experiencing the same behavior.

hanhtd commented 6 years ago

Apache CXF always requires an XML lib processing to support work with SOAP. And now it only support Woodstox 4.2.x and newer as none of the other. Therefore FuelSDK has a transitive dependency to org.codehaus.woodstox:woodstox-core-asl:4.4.1.

The problem is if you project has an dependency with lower version of woodstox lib (in my project = wstx-asl:3.2.7), the class loader may load lower version then it throw exception. Please check your project dependency tree and try to resolve this conflict.

It should not consider as a bug. Please close this ticket.

ayas-swain commented 2 years ago

I faced the same issue recently which took sometime for me to figure out the root cause. Our application's build was running fine on Tomcat-7 but we had upgraded the Tomcat version to Tomcat9 as per a requirement. Application build deployment was successful on one RHEL server while it failed on another similar server. It failed with the below errors -

Error creating bean with name <our app bean name> javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service. Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory, you should either add woodstox or set org.apache.cxf.stax.allowInsecureParser system property to true if an unsafe mode is acceptable.

In my case the issue was the presence of woodstox-core-asl-4.1.2.jar in WEB-INF/lib folder of the app. Our maven dependency tree was bringing both woodstox-core-asl-4.1.2.jar and woodstox-core-6.2.6.jar into the application's build. Though the group id of these 2 jars are different the package name space (com/ctc/wstx)and teh class names inside the jars are exactly same. The underlying implementations of the classes are different though. The woodstox-core-asl-4.1.2 is a very old jar which was released in Aug-2011 while woodstox-core-6.2.6.jar was released in April-2021 whcih is compatible with Tomcat-8 and above. After i excluded woodstox-core-asl from my maven dependency tree the application got deployed successfully on to Tomcat-9 and it ran without any issues.