Cocoon
  1. Cocoon
  2. COCOON-2036

Throw an exception when circular dependencies in servlet connections are detected.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Labels:
      None
    • Affects version (Component):
      Servlet Service Framework - 1.0.0-RC1
    • Fix version (Component):
      Servlet Service Framework - 1.0.0-RC2-dev

      Description

      Circular dependencies in servlet connections lead to a Spring exception [1] in [2] that does not provide any help. The previous implementation (block:) did allow circular dependencies because they were not handled by spring but by custom code.

      Solution would be either to allow them (probably difficult to implement with spring) or, if not, to provide a helpful warning message, that skips this problem. The latter could be a check for embeddedServlet==null and, if not, throw an exception saying "you might have a circular dependency in <servlet-foobar>".

      ---

      [1]:

      The exception is thrown after ServletFactoryBean.getObject() tries to create a proxy for the embeddedServlet, which is null in the case of a circular dependency (one of the circle endpoints is created, but the other will be null).

      Caused by: org.springframework.aop.framework.AopConfigException: Can't proxy null object
              at org.springframework.aop.framework.ProxyFactory.<init>(ProxyFactory.java:49)
              at org.apache.cocoon.servletservice.spring.ServletFactoryBean.getObject(ServletFactoryBean.java:194)
              at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectFromFactoryBean(AbstractBeanFactory.java:1211)

      [2]:
          public Object getObject() throws Exception {
              ProxyFactory proxyFactory = new ProxyFactory(this.embeddedServlet);
              proxyFactory.addAdvice(new ServiceInterceptor());
              if (this.mountPath != null) {
                  proxyFactory.addAdvisor(new MountableMixinAdvisor());
              }
              proxyFactory.addAdvisor(new ServletServiceContextMixinAdvisor());
              return proxyFactory.getProxy();
          }

        Issue Links

          Activity

          Hide
          Grzegorz Kossakowski added a comment -
          Applied in r611562. Thanks Alexander for providing a patch.
          Show
          Grzegorz Kossakowski added a comment - Applied in r611562. Thanks Alexander for providing a patch.
          Hide
          Grzegorz Kossakowski added a comment -
          Sorry, I moved wrong issue.
          Show
          Grzegorz Kossakowski added a comment - Sorry, I moved wrong issue.
          Hide
          Alexander Klimetschek added a comment -
          Patch for cocoon-servlet-service-impl that affects only the ServletFactoryBean.

          It throws an exception with the hint for a possible cyclic dependency. During debugging I also found a problem that appears when you put a non-exisiting bean as a connection value-ref: ServletFactoryBean.getObjectType() is supposed to return null if the type of the object can not yet be determined, ie. when embeddedServlet == null. I fixed that which gives a better exception stacktrace with Spring.
          Show
          Alexander Klimetschek added a comment - Patch for cocoon-servlet-service-impl that affects only the ServletFactoryBean. It throws an exception with the hint for a possible cyclic dependency. During debugging I also found a problem that appears when you put a non-exisiting bean as a connection value-ref: ServletFactoryBean.getObjectType() is supposed to return null if the type of the object can not yet be determined, ie. when embeddedServlet == null. I fixed that which gives a better exception stacktrace with Spring.
          Hide
          Grzegorz Kossakowski added a comment -
          It seems that better handling of super calls eliminate the need for circular dependencies.
          Show
          Grzegorz Kossakowski added a comment - It seems that better handling of super calls eliminate the need for circular dependencies.

            People

            • Assignee:
              Grzegorz Kossakowski
              Reporter:
              Alexander Klimetschek
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development