RESTEasy Tutorial Part-2: Spring Integration

RESTEasy Tutorial Series

RESTEasy Tutorial Part-1: Basics

RESTEasy Tutorial Part-2: Spring Integration

RESTEasy Tutorial Part 3 – Exception Handling

RESTEasy provides support for Spring integration which enables us to expose Spring beans as RESTful WebServices.

Step#1: Configure RESTEasy+Spring dependencies using Maven.

Step#2: Configure RESTEasy+Spring in web.xml

Step#3: Create a Spring Service class UserService and update UserResource to use UserService bean.

Step#4: Same JUnit TestCase to test the REST Webservice described in Part-1.

Important Things to Keep in mind:
1. org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap Listener should be registered before any other listener.
2. You should configure resteasy.servlet.mapping.prefix <context-param> if the HttpServletDispatcher servlet url-pattern is anything other than /*
3. While using Spring integration set resteasy.scan to false or don’t configure resteasy.scan parameter at all.
    Otherwise you may get REST Resource instances(UserResource) from RestEasy instead of Spring container. While running JUnit Tests I observed this random behavior.

4. You should register REST Resource as Spring bean by annotating with @Component or @Service.


  1. Anonymous
      June 9, 2012

    Thank you for this post! I was struggling with the integration of RESTEasy into Spring for about an hour because the official documentation at was just too abstract for me to understand.

    But copying the concepts from your example my code finally worked :-)

  2. Vivek
      December 15, 2012

    Its Perfect. The example is clear and the explanation is kept so Simple

  3. Netanel Weinberg
      April 11, 2013

    Does anyone got a problem when trying to use propertyplaceholderconfigurer and ${something} into a bean's property but the configurer is instantiate only after the bean from some reason? Spring post processor??

  4. Kristian Josef Delos Reyes
      June 20, 2014

    great job men!

  5. Shaz
      September 2, 2014

    Hi Siva,
    This is works perfectly fine in Apache Tomcat 7.0.54 sever but when the same war file deployed in JBoss AS 7 ….deployment gets fail with error message "Caused by: java.lang.NoSuchMethodError: org.jboss.resteasy.spi.InjectorFactory.createPropertyInjector(Ljava/lang/Class;Lorg/jboss/resteasy/spi/ResteasyProviderFactory;)Lorg/jboss/resteasy/spi/PropertyInjector;"
    Any idea why behaviour .?? am using Spring-3.1.0.release and resteasy-3.0.8.Final

  6. Siva Prasad Reddy
      September 2, 2014

    I guess this is due to conflict of JBoss Jar versions with some jars you packaged in war file.
    Make sure you have provided scope for resteasy jars in pom.xml while deploying on JBoss.

Leave a Reply

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