-
Notifications
You must be signed in to change notification settings - Fork 198
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
Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Cannot invoke "String.length()" because "path" is null #3028
Comments
@dstepanov it seems there is an issue integrating Micronaut Data Hibernate Reactive with Testcontainers and Liquibase. I tried everything I could to make it work, the test always fails. |
Please create a sample app |
Any updates on this? I had the same issue, even without liquibase. |
Bump for updates. I am having the same issue with a brand new project without any migration management tooling. |
I investigated this issue and not sure Micronaut can support hibernate reactive with test containers. This is where it is failing in
because the url getting here is from tc url: Instead, you can use Micronaut Test Resources with hibernate reactive. In setup similar to this, would need to have application-prod.properties (or application-dev.properties) and application-test.properties so test resources can figure out it needs to populate connection properties and not inherit from application.properties . |
Thanks for the information. I have always been confused by the difference between Micronaut Test-Resources and Micronaut's testcontainer integration. I know they are two separate items in Microanut Launch. The test-resources documentation can be found here: https://micronaut-projects.github.io/micronaut-test-resources/2.7.0/guide/. Does anyone know where the testcontainers integration documentation can be found? |
I don't think there is separate documentation or support for testcontainers in Micronaut. This is why there is Micronaut Test Resources that sets up container and for example DB connections using test containers. |
I did a little experimenting using Micronaut Launch, creating a seed project with just the testcontainers integration, excluding Micronaut Test Resources. The resulting gradle file only includes the following test related dependencies:
It produces an
I wrote a simple test and confirmed database interactions worked as expected. All without the use of Micronaut Test Resources and without explicitly wiring up a testcontainer. I assumed based on the testcontainers documentation that I would have to configure a container somewhere. I imagine the magic is in jdbc url Either way, thanks for the help. I will look into the test resources solution. |
I would expect this driver is declared somewhere |
Expected Behavior
I initiated a micronaut project with Kotlin on Java 21 and the following features:
I am expecting that the generated test file to work out of the box and the test passes. The test file looks like this:
Actual Behaviour
Instead, I am getting the following error:
Looking at the console a bit deeper, it seems that the SQL client URL is not properly calculated:
Notice the literal value
jdbc:tc:postgresql:16.3:///db
, which should instead look something like thisjdbc:postgresql://localhost:55958/test?loggerLevel=OFF
(the generated URL of the testcontainer)Steps To Reproduce
1- Start a Micronaut Projec with Kotlin on Java 21 and Gradle
2- Install the dependencies:
Micronaut Data Hibernate Reactive
:PostgreSQL DB
:Liquibase
:Testcontainers
:3- Adjust the config files:
application.conf
:application-test.conf
:4- Run any test via
./gradlew test
5- Check the console for the error
Environment Information
JDK version: 21
Kotlin version: 1.9.24
Build Tool: Gradle Kotlin
Test framework: Junit5
Example Application
https://github.com/kareemelzayat/demo-micronaut
Version
4.5.0
The text was updated successfully, but these errors were encountered: