java.lang.NoSuchFieldError: REFLECTION

Or it could be just different versions of com.sun.xml.bind:jaxb-core and com.sun.xml.bind:jaxb-impl. Ensure they are the same across your dependency:tree. I had -core v.2.2.11 and -impl v.2.2.6 in my project which led to the same exception. After setting both versions to 2.2.11 via dependencyManagement section everything became fine.

Difference between Axis2 webservice and CXF web service

The main differences between axis2 web service and CXF web service are as follows: CXF has support for WS-Addressing, WS-Policy, WS-RM, WS-Security, and WS-I BasicProfile. Axis2 supports each of these except for WS-Policy, which will be supported in an upcoming version. CXF was written with Spring in mind; Axis2 is not. Axis2 supports a wider … Read more

JAX-WS = When Apache CXF is installed it “steals” default JDK JAX-WS implementation, how to solve?

Apache CXF (cxf-rt-frontend-jaxws-*.jar to be precise) registers itself as a JAX-WS provider in the JVM. Inside the aforementioned JAR there is a file named: /META-INF/services/javax.xml.ws.spi.Provider with the following contents: org.apache.cxf.jaxws.spi.ProviderImpl If you now look at javax.xml.ws.spi.FactoryFinder#find method you will discover that JDK searches the CLASSPATH for the presence of javax.xml.ws.spi.Provider file and falls back to … Read more

Best way to consume RPC/encoded webservice?

UPDATE My case was solved with hand editing WSDL from encoded to literal (basically under operations input and output use=”literal” was the only replacement) and then I could generate stubs with Apache CXF. It could be done, because endpoint wasn’t parsing RPC/encoded exactly and RPC/encoded spec XML couldn’t be validated against WSDL). Although Axis 1.4 … Read more

JAXB generating JAXBElement instead of String

What I had to do is to wrap jaxb:globalBindings with another jaxb:bindings. <jaxb:bindings version=”2.0″ xmlns:jaxb=”http://java.sun.com/xml/ns/jaxb”> <jaxb:bindings> <jaxb:globalBindings generateElementProperty=”false”/> </jaxb:bindings> </jaxb:bindings> Now everything is working, there is no JAXBElement<String> generated anymore.

How to return a partial JSON response using Java?

If you use Jackson (a great JSON lib – kind of the standard for Java I believe), you may use the @View annotation to filter what you want in the resulting object. I understand that you want something dynamic so it’s a bit more complicated. You will find what you are looking for here: http://www.cowtowncoder.com/blog/archives/2011/02/entry_443.html … Read more

How do I prevent JAXBElement from being generated in a CXF Web Service client?

You have to create a binding file as below, this will get applied globally and use it as wsdl2java – b “bindings.txt” “wsdl” <jaxb:bindings version=”2.1″ xmlns:jaxb=”http://java.sun.com/xml/ns/jaxb” xmlns:xjc=”http://java.sun.com/xml/ns/jaxb/xjc” xmlns:xs=”http://www.w3.org/2001/XMLSchema”> <jaxb:globalBindings generateElementProperty=”false”/> </jaxb:bindings>

How to log Apache CXF Soap Request and Soap Response using Log4j?

You need to create a file named org.apache.cxf.Logger (that is: org.apache.cxf file with Logger extension) under /META-INF/cxf/ with the following contents: org.apache.cxf.common.logging.Log4jLogger Reference: Using Log4j Instead of java.util.logging. Also if you replace standard: <cxf:bus> <cxf:features> <cxf:logging/> </cxf:features> </cxf:bus> with much more verbose: <bean id=”abstractLoggingInterceptor” abstract=”true”> <property name=”prettyLogging” value=”true”/> </bean> <bean id=”loggingInInterceptor” class=”org.apache.cxf.interceptor.LoggingInInterceptor” parent=”abstractLoggingInterceptor”/> <bean id=”loggingOutInterceptor” … Read more