Grails
  1. Grails
  2. GRAILS-2222

Autobinding does not work for spring bean alias

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-RC4
    • Fix Version/s: 1.0.5, 1.1-beta3
    • Component/s: None
    • Labels:
      None

      Description

      1. I created Grails 1.0-rc4 application.
      2. I created the following controller:
        class HelloController {
            def str1
            def str2
            def exampleService
        
            def index = { 
              def serviceResult = exampleService.serviceMethod()
              render "hello $str1 and $str2. $serviceResult"
            }
        }
        
      3. I created the following service:
        class ExampleService {
            def str1
            def str2
        
            boolean transactional = true
        
            def serviceMethod() {
        
        	  "$str1 and $str2"
        
            }
        }
        
      4. I updated resources.xml:
        <?xml version="1.0" encoding="UTF-8"?>
        <beans xmlns="http://www.springframework.org/schema/beans"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
        	
          <bean id="str1" class="java.lang.String"/>
        
          <alias alias="str2" name="str1"/>
        
        </beans>
        
      5. Then I went to http://localhost:8080/myapp/hello and see "hello and null. and null".

      It seems that autobinding does not work with spring aliases both in Controllers and Services.

        Activity

        Hide
        ck added a comment -

        hey- I think this is broken again. You seem to have lost the part of patch that fixed this bug in a later revision. This is just for grails/src/commons/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java- the other two files from the commit seem to be ok. The changes in 6535 for that file are removed in commit 6575. Without the patch aliases don't appear to work in resources.xml. When I reapply it they do, at least for me.

        here's the fix that's now missing:
        http://fisheye.codehaus.org/browse/grails/trunk/grails/src/commons/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java?r1=6409&r2=6535&u=3&ignore=&k=

        here's where it went away:
        http://fisheye.codehaus.org/browse/grails/trunk/grails/src/commons/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java?r1=6571&r2=6575#seg61

        Show
        ck added a comment - hey- I think this is broken again. You seem to have lost the part of patch that fixed this bug in a later revision. This is just for grails/src/commons/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java- the other two files from the commit seem to be ok. The changes in 6535 for that file are removed in commit 6575. Without the patch aliases don't appear to work in resources.xml. When I reapply it they do, at least for me. here's the fix that's now missing: http://fisheye.codehaus.org/browse/grails/trunk/grails/src/commons/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java?r1=6409&r2=6535&u=3&ignore=&k= here's where it went away: http://fisheye.codehaus.org/browse/grails/trunk/grails/src/commons/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java?r1=6571&r2=6575#seg61
        Hide
        Graeme Rocher added a comment -

        Thanks for the heads-up

        Show
        Graeme Rocher added a comment - Thanks for the heads-up
        Hide
        Graeme Rocher added a comment -

        Bulk closing bunch of resolved issues

        Show
        Graeme Rocher added a comment - Bulk closing bunch of resolved issues

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Andrew Osipenko
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development