Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-674

Duplicate Atom Links when Integrating with Spring

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 2.3.1
    • None

    Description

      I've recently started testing out RESTEasy with some spring integration. When attempting to add some atom links to GET output I noticed that the atom links were repeating themselves:
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <collection xmlns:atom="http://www.w3.org/2005/Atom">
      <hello name="Bob" message="Hello Bob" random="89">
      <atom:link rel="add"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello" />
      <atom:link rel="add"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello" />
      <atom:link rel="self"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Bob" />
      <atom:link rel="remove"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Bob" />
      <atom:link rel="update"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Bob" />
      <atom:link rel="self"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Bob" />
      <atom:link rel="remove"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Bob" />
      <atom:link rel="update"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Bob" />
      </hello>
      <hello name="Secure Bob" message="Hello Secure Bob" random="99">
      <atom:link rel="add"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello" />
      <atom:link rel="add"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello" />
      <atom:link rel="self"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Secure%20Bob" />
      <atom:link rel="remove"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Secure%20Bob" />
      <atom:link rel="update"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Secure%20Bob" />
      <atom:link rel="self"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Secure%20Bob" />
      <atom:link rel="remove"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Secure%20Bob" />
      <atom:link rel="update"
      href="https://cpt-jkqc55j.intecbilling.com:8443/rest/resource/hello/Secure%20Bob" />
      </hello>
      </collection>

      My web XML looks as below:

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app id="WebApp_ID" version="2.4"
      xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
      <display-name>RESTEasyTest</display-name>

      <context-param>
      <param-name>resteasy.servlet.mapping.prefix</param-name>
      <param-value>/resource</param-value>
      </context-param>

      <!--
      Spring Context configuration
      -->
      <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:cfg/spring.xml</param-value>
      </context-param>

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

      <listener>
      <listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderListener</listener-class>
      </listener>

      <servlet>
      <servlet-name>Resteasy</servlet-name>
      <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
      </servlet>

      <servlet>
      <servlet-name>other_stuff</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:cfg/empty.xml</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet>
      <servlet-name>more_stuff</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:cfg/more.xml</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
      <servlet-name>Resteasy</servlet-name>
      <url-pattern>/resource/*</url-pattern>
      </servlet-mapping>
      </web-app>

      Removing the DispatcherServlets fixes the problem, however I need the DispatcherServlets for an an already existing project.

      The problem appears to be that the SpringBeanProcessor.onApplicationEvent is getting called multiple times which is causing multiple entries in the ResourceMethodRegistry for the same methods.

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            glenn.keith Glenn Keith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: