2

I'm trying to use a service in my spring boot application. This exact client works fine in netbeans and an older project using spring 3 MVC but when I try to call the same method I get javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory.

I searched a lot and tried different answer but no luck! these are some of question on stackoverflow that I tried:

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

java.lang.RuntimeException: Cannot create a secure XMLInputFactory when deploying on Glassfish

Cannot create a secure XMLInputFactory

Cannot create a secure XMLInputFactory when calling Apache CXF Client from Plain Java

Although passing a VM Option for allowing less secure parsers wasn't a solution for me I tried that. When I added the -Dorg.apache.cxf.stax.allowInsecureParser=1 the first line of code does not throw the specified exception but on second line when I try to get the port a java.lang.NoSuchFieldError: QUALIFIED will be thrown!

Code for calling service:

MessageRelayService messageRelayService = new MessageRelayService();
MessageRelay msgService = messageRelayService.getMessageRelayPort();

CountResult countResult = msgService.getReceivedMessageCount(USERNAME, PASSWORD);

My pom(some parts were omitted for brevity):

<properties>
    ...
    <java.version>1.8</java.version>
    <cxf.version>3.0.0</cxf.version>
    <swagger.version>2.6.0</swagger.version>
    <purchase.version>1.2.4</purchase.version>
    <spring-cloud.version>Camden.SR2</spring-cloud.version>
    ...
</properties>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.7.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
    .
    .
    .
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2</artifactId>
        <version>1.6.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-transport-local</artifactId>
        <version>1.6.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-transport-http</artifactId>
        <version>1.6.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.ws.commons.axiom</groupId>
        <artifactId>axiom-impl</artifactId>
        <version>1.2.13</version>
    </dependency>

    <dependency>
        <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
        <version>1.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    .
    .
    .
</dependencies>
...

Any help would be greatly appreciated.

Ali M
  • 801
  • 11
  • 23
  • Have you tried to add the following dependency: org.apache.cxf cxf-spring-boot-starter-jaxws 3.1.12 ? See http://cxf.apache.org/docs/springboot.html – pringi Jul 17 '18 at 07:55
  • Done it and no luck! But if I'm not mistaken this is for serving service I'm trying to use from an endpoint. – Ali M Jul 17 '18 at 08:31
  • 1
    Although not reporting the same problem, see if this gives you any hint: https://mail-archives.apache.org/mod_mbox/cxf-users/201706.mbox/%3C1498020844227-5781362.post@n5.nabble.com%3E. Try not to inherit from spring-boot-starter-parent. Add the dependencies explicitly. Maybe you are having conflicting versions on dependencies – pringi Jul 17 '18 at 10:18
  • Thank @pringi but woodstux dependency removed after version 3 of cfx – Ali M Jul 17 '18 at 11:56
  • I'll try to add dependencies explicitly and get back to you with the results thanks – Ali M Jul 17 '18 at 11:57
  • Thanks @pringi with your kind help I finally solved the problem. – Ali M Aug 05 '18 at 07:02

1 Answers1

2

After a lot of search and trying all kinds of things with help of @pringi I returned back to my pom and found out the problem so I thought to write an answer maybe it'll help somebody someday!

The problem was that I had some dependencies in my pom that weren't needed and they could be removed and they conflicted with cxf! So I removed these dependencies and voila!

    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-transport-local</artifactId>
        <version>1.6.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-transport-http</artifactId>
        <version>1.6.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.ws.commons.axiom</groupId>
        <artifactId>axiom-impl</artifactId>
        <version>1.2.13</version>
    </dependency>
    <dependency>
        <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
        <version>1.6.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.neethi</groupId>
        <artifactId>neethi</artifactId>
        <version>3.0.3</version>
    </dependency>

    <dependency>
        <groupId>org.apache.ws.commons.axiom</groupId>
        <artifactId>axiom-api</artifactId>
        <version>1.2.13</version>
    </dependency>

    <dependency>
        <groupId>org.apache.ws.commons.schema</groupId>
        <artifactId>XmlSchema</artifactId>
        <version>1.4.2</version>
    </dependency>

Thanks To All!

Ali M
  • 801
  • 11
  • 23