Environment Setup
A CXF project needs a JDK, Maven, and a small set of runtime dependencies. The standalone examples in this course use CXF's embedded Jetty transport, so no application server is required for the first chapters.
Install the toolchain
java -version
mvn -version
Use Java 17 or newer with CXF 4.x. Maven 3.8 or newer is sufficient. Confirm that JAVA_HOME points to the same JDK that Maven uses; a mismatch produces confusing compile errors.
Create a Maven project
mvn archetype:generate -DgroupId=com.example \
-DartifactId=cxf-demo -Dversion=1.0.0 \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DinteractiveMode=false
Add CXF dependencies
<properties>
<maven.compiler.release>17</maven.compiler.release>
<cxf.version>4.0.5</cxf.version>
</properties>
<dependencies>
<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-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
cxf-rt-frontend-jaxws brings the JAX-WS runtime and the jakarta.jws annotations. The Jetty transport lets a main method publish an endpoint without a servlet container. Later chapters add cxf-rt-frontend-jaxrs and cxf-rt-transports-jms when those styles are introduced.
Project layout
cxf-demo/
├── pom.xml
└── src/
└── main/
├── java/com/example/...
└── resources/
Keep service interfaces, implementations, and launchers in separate packages once the project grows. A small package layout such as com.example.service, com.example.server, and com.example.client keeps the generated WSDL and client code easy to reason about.
Run a class from Maven
Add the exec plugin so the examples can start with one command:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.2.0</version>
</plugin>
mvn -q compile exec:java -Dexec.mainClass=com.example.server.HelloServer
Verify the setup
Create a trivial class that prints a line and run it. If Maven compiles and the class starts, the toolchain is ready. The next chapter publishes an actual endpoint and opens it in a browser.
Common setup problems
- Wrong Java version shows up as an unsupported class file version during compilation.
- Missing Jetty transport produces a "no conduit" error when publishing over HTTP.
- Port already in use means another process holds 8080; change the address or stop the process.
- Mixed javax and jakarta imports compile but fail at runtime; pick one API generation for the whole project.
Back to course overview · Previous: Introduction · Next: Apache CXF With POJO