You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have some Domains in the src/main/groovy directory, in order to bundle Module code together in a prettier way. For this, we use the annotations @Entity and @Artefact("domain") which works great, as long as we put them in the default application package. However, if we another package, and use @ComponentScan(basePackages = ["package1", "package2"]) the domains are not recognized in the second package, even with the same annotations.
Actual Behaviour
Instead of a functional Entity, when calling the list() command on an Entity from package2, i get this error:
Caused by: java.lang.IllegalStateException: Either class [pms.Foo] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.
Steps To Reproduce
I've added a sample project to this issue. It includes the packages "dila" and "pms". There are two Entities, Foo and Test, of which Test loads fine, but Foo doesnt. To test this, I've added a list command for each in the TestController which can be accessed under http://localhost:8080/test/listFoo and http://localhost:8080/test/listTest
However, if we another package, and use @componentscan(basePackages = ["package1", "package2"]) the domains are not recognized in the second package, even with the same annotations.
Is @ComponentScan relevant to discovering domain classes in Grails 6.2.0?
Expected Behavior
We have some Domains in the src/main/groovy directory, in order to bundle Module code together in a prettier way. For this, we use the annotations
@Entity
and@Artefact("domain")
which works great, as long as we put them in the default application package. However, if we another package, and use@ComponentScan(basePackages = ["package1", "package2"])
the domains are not recognized in the second package, even with the same annotations.Actual Behaviour
Instead of a functional Entity, when calling the list() command on an Entity from package2, i get this error:
Caused by: java.lang.IllegalStateException: Either class [pms.Foo] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.
Steps To Reproduce
I've added a sample project to this issue. It includes the packages "dila" and "pms". There are two Entities, Foo and Test, of which Test loads fine, but Foo doesnt. To test this, I've added a list command for each in the TestController which can be accessed under http://localhost:8080/test/listFoo and http://localhost:8080/test/listTest
grails-app/init/dila/Application.groovy:
src/main/groovy/dila/Test.groovy
src/main/groovy/pms/Foo.groovy
TestController.groovy
sample_project_multipackage.zip
Environment Information
Example Application
No response
Version
6.2.0
The text was updated successfully, but these errors were encountered: