Friday, January 6, 2012

Maven archetype for creating CXF JAX-RS applications

A number of Maven plugins that CXF JAX-RS users could try for generating the initial code they could build upon for creating working applications was close to zero not too long ago, in fact it was actually 0.

Then we added a wadl2java plugin so the numbers started to look better :-).

And now starting from CXF 2.5.1 an archetype plugin for creating Spring-based JAX-RS applications is also available, all thanks to Benson.

Please see this page for more information.
The generated project will get the integration tests running too, so having a simple end-to-end application created and tested in less than a minute is really cool.


noosy said...

Hi Sergey,

I tried to use the cxf-jaxrs-service archetype. It created the skeleton project fine however when the integration tests are executed I see:

testPing(my.package.cxfjaxrsservicearchetype.HelloWorldIT) Time elapsed: 0.462 sec <<< ERROR!
java.lang.NoClassDefFoundError: org/apache/cxf/ws/policy/PolicyException


testJsonRoundtrip(my.package.cxfjaxrsservicearchetype.HelloWorldIT) Time elapsed: 0.019 sec <<< ERROR!
java.lang.NoClassDefFoundError: org/apache/cxf/ws/policy/PolicyException

Are you able to shed some light? I have a Nexus repo in the mix. Tried within NetBeans and command line with the same result.

I'm new to Maven/Nexus..

With thanks

noosy said...


I posted previously regarding:

java.lang.NoClassDefFoundError: org/apache/cxf/ws/policy/PolicyException

..when running integration tests.

This issue was resolved by me changing the dependency cxf-rt-frontend-jaxrs from version 2.6.0-SNAPSHOT to version 2.5.1.


Sergey Beryozkin said...

Hi, it is a temporarily issue on the 2.6.2-SNAPSHOT trunk due to the major refactoring to do with making individual modules OSGI-fied


Hélder Sousa said...

Hi Sergey,

I am trying to generate java code client from the WADL to call a REST service using cxf-wadl2java-plugin maven plugin, but the documentation in CXF is not very useful for this (

Do you have any idea or point into the right direction?

Thank you for your time!

Sergey Beryozkin said...

wadltojava will only generate the interface (and optionally server impl classes); for client you;d need then to use CXF JAXRSClientFactory to create a proxy from the generated interface.

If you have more questions then please ask on the cxf users list, thanks