Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use versions from grails-bom in example apps #920

Draft
wants to merge 13 commits into
base: 9.0.x
Choose a base branch
from

Conversation

matrei
Copy link
Contributor

@matrei matrei commented Nov 3, 2024

And remove unused versions from gradle.properties

gradle.properties Show resolved Hide resolved
examples/grails3-hibernate5/build.gradle Outdated Show resolved Hide resolved
examples/grails3-hibernate5/build.gradle Outdated Show resolved Hide resolved
@matrei matrei marked this pull request as draft November 5, 2024 22:43
@matrei matrei force-pushed the matrei/use-bom-in-apps branch 3 times, most recently from 6fc1e46 to 218d480 Compare November 6, 2024 15:52
@matrei matrei force-pushed the matrei/use-bom-in-apps branch 3 times, most recently from bc85678 to 7c1506e Compare November 7, 2024 14:33
Copy link
Contributor

@codeconsole codeconsole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matrei have you tried running all these examples to see if they work as expected?

Do you know why @EnableAutoConfiguration(exclude = DataSourceTransactionManagerAutoConfiguration) was there and commented out and if it still needs to be excluded. It can be excluded in application.yml if necessary.

@matrei
Copy link
Contributor Author

matrei commented Nov 8, 2024

have you tried running all these examples to see if they work as expected?

Yes

Do you know why @EnableAutoConfiguration(exclude = DataSourceTransactionManagerAutoConfiguration) was there and commented out and if it still needs to be excluded. It can be excluded in application.yml if necessary.

This was probably to prevent Spring Boot from configuring a transaction manager as GORM also does this and there is a problem when two are configured. It seems this is not needed anymore when using the org.grails.plugins:hibernate5 plugin as it sets it's transaction manager as primary.

I actually had to add something like that to examples-spring-boot-hibernate5 to make it not bomb when accessing the database from the started app: @SpringBootApplication(exclude = HibernateJpaAutoConfiguration). It seems, this is not handled by default by the gorm-hibernate5-spring-boot plugin.

And remove unused versions from `gradle.properties`
As `ContainerGebSpec` is used now, `webdriver-binaries-gradle-plugin` can be removed.
- `AnotherBookService`: Make `save()` method use passed book title
- `Application`: Remove unused imports and old comment
- `application.yml`: Format properly with 2 spaces and group config settings better
- `logback.xml`: Correct faulty pattern
- `build.gradle`: Use correct dependencies and narrow the scopes. Apply Gradle plugins in subproject instead of having logic and conditions in the root build file apply them - much easier to see what's being applied.
- `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config.
- `logback.xml`: Correct faulty pattern
- `build.gradle`: Use correct dependencies and narrow the scopes. Switch from `tomcat-jdbc` to `HikariCP` as this will be the new default. Apply Gradle plugins in subproject instead of having logic and conditions in the root build file apply them - much easier to see what's being applied.
- `BookControllerUnitSpec`: Remove unused imports and bean definition of deprecated `MimeTypesGrailsPlugin`.
- `UrlMappings`: Move to package so it is pickup up.
- `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config.
- `logback.xml`: Correct faulty pattern
- `Application`: Remove unused imports and old comment
- `build.gradle`: Use correct dependencies and narrow the scopes. Switch from `tomcat-jdbc` to `HikariCP` as this will be the new default. Apply Gradle plugins in subproject instead of having logic and conditions in the root build file apply them - much easier to see what's being applied. Use `astTransformation` configuration for dependencies that needs to be both `compileOnly` and `integrationTestCompileOnly`.
- `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config.
- `logback.xml`: Correct faulty pattern
- `AnotherBookService`: Make `save()` method use passed book title
- `PartionedMultiTenancySpec`: Remove unused imports
- `Application`: Remove unused imports and old comment
- `build.gradle`: Use correct dependencies and narrow the scopes. Switch from `tomcat-jdbc` to `HikariCP` as this will be the new default. Apply Gradle plugins in subproject instead of having logic and conditions in the root build file apply them - much easier to see what's being applied.
- `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config.
- `logback.xml`: Correct faulty pattern
- `AnotherBookService`: Make `save()` method use passed book title
- `SchemaPerTenantSpec`: Remove unused imports
- `Application`: Remove unused imports and old comment
- `build.gradle`: Use correct dependencies and narrow the scopes. Switch from `tomcat-jdbc` to `HikariCP` as this will be the new default. Apply Gradle plugins in subproject instead of having logic and conditions in the root build file apply them - much easier to see what's being applied.
- `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config.
- `logback.xml`: Correct faulty pattern
- `Customer`: Add no-args constructor needed for proxying
- `ProxySpec`: Remove unused imports
- `Application`: Remove unused imports and old comment
- `build.gradle`: Use correct dependencies and narrow the scopes. Switch from `tomcat-jdbc` to `HikariCP` as this will be the new default. Apply Gradle plugins in subproject instead of having logic and conditions in the root build file apply them - much easier to see what's being applied. Change version variable name from `hibernateGroovyProxy` to `yakworksHibernateGroovyProxyVersion`.
- `application.yml`: Format properly with 2 spaces remove unused config.
- `Application`: Exclude `HibernateJpaAutoConfiguration` to avoid duplicate transaction managers: java.lang.ClassCastException: class org.springframework.orm.jpa.EntityManagerHolder cannot be cast to class org.springframework.orm.hibernate5.SessionHolder (org.springframework.orm.jpa.EntityManagerHolder and org.springframework.orm.hibernate5.SessionHolder are in unnamed module of loader 'app')
- `BookController`: Add `@ReadOnly` to `books()` action to get a session for the `Book.list()` method.
- `build.gradle`: Use correct dependencies and narrow the scopes. Switch from `tomcat-jdbc` to `HikariCP` as this will be the new default. Apply Gradle plugins in subproject instead of having logic and conditions in the root build file apply them - much easier to see what's being applied. Add version variable `springBootGradlePluginVersion`.
The fix for #450 did not really fit in `examples-grails-data-service`.

This commit adds a new example project, that shows the problem and that it now works (taken from https://github.com/grails-core-issues-forks/multitenantcomposite).
- `MultitenantBook.groovy`: Remove as extracted to examples-issue-450
- `application.yml`: Format properly with 2 spaces and group config settings better. Remove unused config.
- `ClassUsingAService`: Remove dependency on `grails-spring-security-rest`. No need to depend on outside plugins for this test. New test `ServiceInjectionSpec` exercising issue 202.
- `TestService`: Remove unused `transactionService` property
- `logback.xml`: Correct faulty pattern
Use correct dependencies and narrow the scopes. Switch from `tomcat-jdbc` to `HikariCP` as this will be the new default. Apply Gradle plugins in subproject instead of having logic and conditions in the root build file apply them - much easier to see what's being applied.
@codeconsole
Copy link
Contributor

codeconsole commented Nov 8, 2024

I actually had to add something like that to examples-spring-boot-hibernate5 to make it not bomb when accessing the database from the started app: @SpringBootApplication(exclude = HibernateJpaAutoConfiguration). It seems, this is not handled by default by the gorm-hibernate5-spring-boot plugin.

The correct behavior I am finding is to not have to use these at all and to reconfigure the plugins to work with the AutoConfigurations. In most cases the AutoConfigurations do 2x the work because what happens is the AutoConfigurations run first, create the service and then Grails creates the same service with the same name. This is terribly inefficient.

The best fixes in these scenarios are to create the bean definition before the Autoconfiguration. When not possible, you can also create a javaconfig for a null placeholder definition so that it stops the AutoConfiguration as well.

These issues are usually masked due to bean definition overriding. enabled by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants