You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "whorvath2 (via GitHub)" <gi...@apache.org> on 2026/08/19 22:38:18 UTC

[I] Service beans not auto-injecting into other service beans without @Autowired [grails-core]

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

   ### Expected Behavior
   
   Service beans that depend on other service beans shouldn't have to add `@Autowired` to their fields to have them injected (unless that's intended behavior; I checked the upgrade guidance this time but couldn't find anything.)
   
   ### Actual Behaviour
   
   I have a collection of service beans, some of which have other service beans as fields. The field beans were auto-injected into their enclosing services in M3, but aren't doing so in M5 (i.e., the field values are `null`), resulting in `InvocationTargetException`s when those field's methods are called. However, I found that adding `@Autowired` to the fields forces the injections. For example, here's a before:
   ```
   @Service
   class LicenseService {
   
       InvoiceService invoiceService
       ProjectUserService projectUserService
       ProjectService projectService
   ```
   And here's what it looks like now, which allows the `licenseService` to work when (e.g.) it uses its `invoiceService` instance:
   ```
   @Service
   class LicenseService {
   
       @Autowired
       InvoiceService invoiceService
       @Autowired
       ProjectUserService projectUserService
       @Autowired
       ProjectService projectService
   ```
   
   ### Steps To Reproduce
   
   _No response_
   
   ### Environment Information
   
   [build.gradle](https://github.com/user-attachments/files/31242426/build.gradle.txt)
   
   ------------------------------------------------------------
   Gradle 9.5.1
   ------------------------------------------------------------
   
   Build time:    2026-05-12 13:19:42 UTC
   Revision:      fd78213f09782e62ca4957f9cfd3d90c6c3f1767
   
   Kotlin:        2.3.20
   Groovy:        4.0.29
   Ant:           Apache Ant(TM) version 1.10.15 compiled on August 25 2024
   Launcher JVM:  25.0.3 (Amazon.com Inc. 25.0.3+9-LTS)
   Daemon JVM:    /Users/bhorvath/.sdkman/candidates/java/25.0.3-amzn (no Daemon JVM specified, using current Java home)
   OS:            Mac OS X 26.6.2 aarch64
   
   | Grails Version: 8.0.0-M5
   | JVM Version: 25.0.3
   
   
   ### Example Application
   
   _No response_
   
   ### Version
   
   8.0.0-M5


-- 
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: notifications-unsubscribe@grails.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Service beans not auto-injecting into other service beans without @Autowired [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on issue #16177:
URL: https://github.com/apache/grails-core/issues/16177#issuecomment-5365097929

   Are you using the `@Service`, as in the annotation for Data Services? 


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Service beans not auto-injecting into other service beans without @Autowired [grails-core]

Posted by "ruthst00 (via GitHub) via notifications" <no...@grails.apache.org>.
ruthst00 commented on issue #16177:
URL: https://github.com/apache/grails-core/issues/16177#issuecomment-6540959032

   @jdaugherty, @borinquenkid, I created a [sample app](https://github.com/ruthst00/16177-service-bean-auto-inject) that reproduces this issue for services stored in `src/main/groovy` which are not conventional Grails service artifacts.  Placing all services in `grails-app/services` on 8.0.0-M5 injected every dependency successfully, with or without Spring `@Service` and component scanning.
   
   @whorvath2, can you please provide your `@Service` import, service source locations, component-scan configuration, or an example application that reproduces this problem?


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Service beans not auto-injecting into other service beans without @Autowired [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on issue #16177:
URL: https://github.com/apache/grails-core/issues/16177#issuecomment-5365162559

   @borinquenkid if these are data services, do you mind taking a look? 


-- 
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: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org