xpusostomos opened a new issue, #14174:
URL: https://github.com/apache/grails-core/issues/14174

   ### Expected Behavior
   
   
   I have the below code in a grails 5.x project that works, and I'm trying to 
upgrade it to 6.x, specifically 6.2.3 and no matter what I seem to do, the 
reference to Listener won't compile, it can't find the class.  I took a new 
create-app template project 6.2.3 and dropped the code below into a service/ 
class and it won't compile either.
   
   I can't see any mention of the feature disappearing, and from what I can 
see, the class seems to still exist in grails... and yet it won't build. I've 
spent quite a bit of time on it, and I'm baffled. 
   
   ```
   import grails.events.annotation.gorm.Listener
   import grails.events.annotation.Events
   import org.grails.datastore.mapping.engine.event.PreUpdateEvent
   import org.grails.datastore.mapping.engine.event.ValidationEvent
   
   class RecordUserAuditService {
       def springSecurityService
   
       @Listener([User,UserRole])
       void onPreUpdate(PreUpdateEvent event) {
          User user = springSecurityService.currentUser
           event.entityAccess.setProperty('userUpdated', user)
       }
   
       @Listener([User,UserRole])
       void onValidate(ValidationEvent event) {
           User user = springSecurityService.currentUser
           if (!event.entityAccess.getProperty('userCreated')) {
               event.entityAccess.setProperty('userCreated', user)
           }
           if (!event.entityAccess.getProperty('userUpdated')) {
               event.entityAccess.setProperty('userUpdated', user)
           }
       }
   }
   ```
   
   
   
   ### Actual Behaviour
   
   Compile error
   
   ```
   ./gradlew build
   
   > Task :compileGroovy FAILED
   startup failed:
   /home/chris/GIT/myApp623/grails-app/services/RecordUserAuditService.groovy: 
2: unable to resolve class grails.events.annotation.gorm.Listener
    @ line 2, column 1.
      import grails.events.annotation.gorm.Listener
      ^
   
   /home/chris/GIT/myApp623/grails-app/services/RecordUserAuditService.groovy: 
3: unable to resolve class grails.events.annotation.Events
    @ line 3, column 1.
      import grails.events.annotation.Events
      ^
   ```
   
   ### Steps To Reproduce
   
   1. grails create-app myApp
   2. Copy the above code into grails-app/services/RecordUserAuditService.groovy
   3. ./gradlew build
   
   ### Environment Information
   
   linux
   java 17.0.14
   
   ### Example Application
   
   _No response_
   
   ### Version
   
   6.2.3


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to