Grails
  1. Grails
  2. GRAILS-6278

Scoped service proxy doesnt work anymore after upgrade to 1.3

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.3 final
    • Fix Version/s: 1.3.5
    • Component/s: None
    • Labels:
      None

      Description

      I am using the convential proxy support and after upgrading from 1.2 to 1.3 it gave this error:

      "bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'"

      When setting service scope back to singleton and uncommenting proxy support in resources.groovy it works again.
      I think this might be related to:
      http://markmail.org/message/4elaxmnsikprsmhb#query:cxf%20%22object%20is%20not%20an%20instance%20of%20declaring%20class%22+page:1+mid:rtmqxvudjse5ccbm+state:results
      ...but trying to prefix targetBeanName with # doesnt work.

      proxy support in resources.groovy
       testService(TestService) {
       authenticateService = ref("authenticateService")
       }
      		
      testServiceProxy(ScopedProxyFactoryBean) { 
       targetBeanName = 'testService'
       proxyTargetClass = true
      }
      

      within the testService i was using session scope

        Issue Links

          Activity

          Hide
          Graeme Rocher added a comment -

          I cannot reproduce this. Attached is an app that uses the configuration described. Please attach an example that does reproduce this issue.

          Show
          Graeme Rocher added a comment - I cannot reproduce this. Attached is an app that uses the configuration described. Please attach an example that does reproduce this issue.
          Hide
          Luke Daley added a comment -

          Please try the Grails scoped proxy plugin and see if that works for you.

          http://github.com/alkemist/grails-scoped-proxy

          Show
          Luke Daley added a comment - Please try the Grails scoped proxy plugin and see if that works for you. http://github.com/alkemist/grails-scoped-proxy
          Hide
          Goran Ehrsson added a comment -

          I also got problems related to this when upgrading from 1.2.2 to 1.3.1
          Exception:
          com.mycompany.TargetService cannot be cast to com.mycompany.TargetService$$EnhancerByCGLIB$$6363d510

          resources.groovy:
          targetService(com.mycompany.TargetService)
          targetScopeProxy(org.springframework.aop.scope.ScopedProxyFactoryBean)

          { targetBeanName="targetService" proxyTargetClass=true }

          But I guess the above configuration was added back when I used grails 1.0.3/1.0.4 and wanted to call services from taglib code. I removed it now and the application still works ok. So it's not a problem for me anymore.

          Show
          Goran Ehrsson added a comment - I also got problems related to this when upgrading from 1.2.2 to 1.3.1 Exception: com.mycompany.TargetService cannot be cast to com.mycompany.TargetService$$EnhancerByCGLIB$$6363d510 resources.groovy: targetService(com.mycompany.TargetService) targetScopeProxy(org.springframework.aop.scope.ScopedProxyFactoryBean) { targetBeanName="targetService" proxyTargetClass=true } But I guess the above configuration was added back when I used grails 1.0.3/1.0.4 and wanted to call services from taglib code. I removed it now and the application still works ok. So it's not a problem for me anymore.
          Hide
          Steve Shucker added a comment -

          I've been able to reproduce this since upgrading from 1.2.1 to 1.3.2. I'm attaching an app with a test case demonstrating the problem. The problem manifests itself differently depending on whether the service is marked as a scoped proxy in an xml or groovy bean definition (per http://jira.codehaus.org/browse/GRAILS-1697). I've included both contexts in my example, but commented out the beanbuilder version.

          Show
          Steve Shucker added a comment - I've been able to reproduce this since upgrading from 1.2.1 to 1.3.2. I'm attaching an app with a test case demonstrating the problem. The problem manifests itself differently depending on whether the service is marked as a scoped proxy in an xml or groovy bean definition (per http://jira.codehaus.org/browse/GRAILS-1697 ). I've included both contexts in my example, but commented out the beanbuilder version.
          Hide
          Graeme Rocher added a comment -

          A workaround is to specify a custom getMetaClass() implementation in the TestService of the attached application:

          MetaClass getMetaClass() { GroovySystem.metaClassRegistry.getMetaClass(TestService)}
          
          Show
          Graeme Rocher added a comment - A workaround is to specify a custom getMetaClass() implementation in the TestService of the attached application: MetaClass getMetaClass() { GroovySystem.metaClassRegistry.getMetaClass(TestService)}
          Hide
          Graeme Rocher added a comment -
          Show
          Graeme Rocher added a comment - Related to http://jira.codehaus.org/browse/GROOVY-3463
          Hide
          Luke Daley added a comment -

          I'll verify this is fixed with the inclusion of Groovy 1.7.5

          Show
          Luke Daley added a comment - I'll verify this is fixed with the inclusion of Groovy 1.7.5
          Show
          Luke Daley added a comment - http://github.com/grails/grails-core/commit/56494650febddfee34d294db27c28afec3cbfdea

            People

            • Assignee:
              Luke Daley
              Reporter:
              Andre
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development