CXF 2.7.x Compatible with Woodstox via Maven

The CXF documentation says that version 2.7.x requires Woodstox cookies, not under version 4.2.0, to be available in the classpath.

Can someone please suggest Maven dependencies for Woodstox for working with CXF?

The main problem is that when I try to use the cxf client, the exception "Unable to create secure XMLInputFactory" is thrown. According to various forums ( for example ), you can use the system property "org.apache.cxf.stax.allowInsecureParser" to solve the problem, but it doesn’t look very good. So maven dependencies are the way to go ...

Thanks in advance.

+7
source share
3 answers

Well, finally, I have a solution. First of all, I want to thank StaxMan for the help.

My environment: Weblogic 11g, CXF 2.7.5

The problem is that WLS already contains implementations for the StAX API and xml parsers, so the application does not see the Woodstox parser when using CXF.

Here is the pom.xml:

<!-- CXF --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-api</artifactId> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> </dependency> 

and the main part is weblogic-application.xml located in the resources / META -INF /:

  <prefer-application-packages> <package-name>com.ctc.wstx.*</package-name> <package-name>org.apache.*</package-name> </prefer-application-packages> 

Remember that if this can happen, the errors are "NoClassDefinition". If so, add maven dependencies containing missing classes.

Hope this helps someone.

+6
source

This worked for me without impl package application preferences:

 <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> <exclusions> <exclusion> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http</artifactId> <version>${cxf.version}</version> </dependency> <!-- Jetty is needed if you're using the CXFServlet --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> <version>${cxf.version}</version> </dependency> 
+4
source

The only way to solve the problem now is to add such lines to the spring context:

 <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetObject"> <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass" value="java.lang.System" /> <property name="targetMethod" value="getProperties" /> </bean> </property> <property name="targetMethod" value="putAll" /> <property name="arguments"> <util:properties> <prop key="org.apache.cxf.stax.allowInsecureParser">true</prop> </util:properties> </property> </bean> 
+3
source

All Articles