Ehcache With CXF Web Service

Ehcache With CXF Web Service explains about the step by step details of Creating / Developing restful services using Apache CXF, Eclipse and Ehcache

Apache CXF is a free and open source project, and a fully featured Webservice framework. It helps you building webservices using different front-end API's, like as JAX-RS and JAX-WS.

Ehcache is a famous open source caching implementation available in java, By using caching technique, we can reduce the method invocation and reduce the response time dramatically. Ehcache consists with more functionalities as compared to spring cache

You can see the below example, which is demonstrate Ehcache With CXF Web Service


You can also read article about Spring Cache With CXF Web Service

Required Libraries

You need to download

  1. JDK 7
  2. Eclipse 4.2
  3. CXF-2.7.3
  4. Tomcat 7

Following jar must be in classpath (You need to download spring 3.1 or higher separately)

  1. aopalliance-1.0.jar
  2. commons-logging-1.1.1.jar
  3. cxf-2.7.3.jar
  4. httpasyncclient-4.0-beta3.jar
  5. httpclient-4.2.1.jar
  6. httpcore-4.2.2.jar
  7. httpcore-nio-4.2.2.jar
  8. neethi-3.0.2.jar
  9. org.springframework.aop-3.1.1.RELEASE.jar
  10. org.springframework.asm-3.1.1.RELEASE.jar
  11. org.springframework.beans-3.1.1.RELEASE.jar
  12. org.springframework.context-3.1.1.RELEASE.jar
  13. org.springframework.core-3.1.1.RELEASE.jar
  14. org.springframework.expression-3.1.1.RELEASE.jar
  15. org.springframework.web-3.1.1.RELEASE.jar
  16. wsdl4j-1.6.2.jar
  17. jaxb-impl-2.2.6.jar
  19. slf4j-api-1.6.2.jar
  20. jettison-1.3.3.jar (JSON library)
  21. ehcache-core-2.5.1.jar
  22. cglib-nodep-2.1_3.jar

Ehcache With CXF Web Service

I am creating a sample restful service project that pass Student object and return with some changes on that object. The service is using simple POJO (Plain Old Java Object) bean.

Firstly create a Dynamic Web Project (File->New->Dynamic Web Project) named "CXFRestfulTutorial" according to following screenshot

Create CXF Project Ehcache With CXF Web Service

Create a Student Object

package com.student;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "Student")
public class Student {
private String name;

public String getName() {
return name;

public void setName(String name) { = name;


1 2 3 Next

1 Responses to "Ehcache With CXF Web Service"
  1. Jeevan 2012-04-25 07:48:04.0

Your email address will not be published. Required fields are marked *