1 Reply Latest reply on May 18, 2017 1:51 AM by rajagopaly

    Resteasy+Spring Inconsistant Autowiring

    rajagopaly

      Hi,

       

      I am integrating Resteasy(resteasy-jaxrs-2.3.1.GA.jar) with Spring(4.3.4) with  resteasy-spring-2.3.1.GA.jar. I have  customized ContextLoaderListener configured :

       

      My Autowiring is inconsistant, some times it works some times it will not work, (it's in different patterns, one time it work, the second time it will not work, one time it works only with get/post and will not work with the other method (get/post).))

       

      web.xml: (exluded mappings)

       

       

      <context-param>

            <param-name>resteasy.scan</param-name>

            <param-value>true</param-value>

         </context-param>

         <context-param>

            <param-name>resteasy.servlet.mapping.prefix</param-name>

            <param-value>/rest</param-value>

         </context-param>

       

          <context-param>

              <param-name>contextConfigLocation</param-name>

              <param-value>

                  /WEB-INF/spring/spring-beans.xml

              </param-value>

          </context-param>

         

          <listener>

              <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>

          </listener>

          <listener>

           <listener-class> org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap </listener-class>

          </listener>

        

         

           <listener>

            <listener-class>com.skillcheck.web_management.restServices.SpringRestEasyContextLoaderListener</listener-class>

         </listener>

              <servlet>

              <servlet-name>rest</servlet-name>

              <servlet-class>

                  org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher

              </servlet-class>

              <init-param>

                  <param-name>javax.ws.rs.Application</param-name>

                  <param-value>com.skillcheck.web_management.restServices.SelectionRestConfig</param-value>

              </init-param>

          </servlet>

       

      spring-beans.xml :

       

        <context:component-scan base-package="com.skillcheck.web_management" />

       

      i am suing annotation configiguration

       

       

      @Configuration

      @EnableJpaRepositories(basePackages ="com.xxxx")

      public class SpringApplicationConfig{

      // which has my db configuration.... repositories and entities are good... loading and working when it is invokded

      }

        • 1. Re: Resteasy+Spring Inconsistant Autowiring
          rajagopaly

          Problem is with

           

           

          <context-param>

                <param-name>resteasy.scan</param-name>

                <param-value>true</param-value>

             </context-param>

           

          When integrating with Spring we have to make resteasy.scan as false or we can remove this entry .

          And we have to manually configure resteasy components as subclass of Application

          : <param-name>javax.ws.rs.Application</param-name>

           

          It Worked For me.

          1 of 1 people found this helpful