-
Notifications
You must be signed in to change notification settings - Fork 617
Reactive client is initialised with an invalid (null
) database selection.
#2488
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
Comments
I think the first error might be related to the fact that SDN 6.2.x requires Spring 5.3.16 https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#dependencies.spring-framework But I can't find which version of Spring Framework is needed for SDN 6.1.X Are there any plans on implementing template.saveAs() for SDN 6.0.X? Thank you |
After trying to update Spring Boot 2.4.2 to 2.5.x and 2.6.x finally I made it work upgrading to Spring Boot 2.4.13 which brings Spring's spring-core 5.3.13 which seems enough to make SDN work. Another issue I'm still experiencing is that my @DataNeo4jTest won't run as it fails to load Application Context with the same error as my first comment.
And this is the error message
Note how it tries to load the ReactiveNeo4jClient even though I'm using the imperative repositories. Another thing to note is that it looks like it's ignoring my @activeprofiles("test) annotation because it is loading some configurations that only exist in my src/resources/application.yml file |
Starting with 6.1.x we pushed the ability to use the database selection down to the I assume that you are defining them in several places. Most likely: You are defining the A reproducer with your / a similar configuration would be helpful. Side note: I do not know what exactly happens in your configuration, but the ReactiveNeo4jClient message will only appear in the reactive Neo4jClient. |
Thanks for the reply, @meistermeier . Yes, I'm autowiring the Neo4jTemplate in several places in our application. The thing is I only get that error when running our tests, even more so, when I only run that test because we also have some unit tests that run without any problems. Ok, I'll try to make a reproducer for you guys. I'll be updating this comment as soon as I have it ready. Thank you. |
Is there any progress on a reproducer or did you find the problem in your test code? |
Hi @meistermeier, thanks for reaching out. |
I assume this really could have been just a configuration problem. If it's ok for you, I will close this issue for now. If you are facing it again and :) can give us something to reproduce it, feel free to re-open it. |
Hi @meistermeier, Yesterday we made it work. We did so by explicitly excluding ReactiveNeo4jDataAutoconfiguration when running our Integration Tests using
I still don't know why the annotations we are using forces Spring to load ReactiveNeo4jDataAutoconfiguration along with other ReactiveNeo4j Beans, guess we'll have to take a deeper look but I think it's mainly because we're not using exclusively the required ones for IT testing. Is there any sample project with IT tests + embedded database? So we can take a look and see how to configure ours properly Thanks |
I cannot provide you any guidelines. Not that we don't have any projects or examples in various repositories but it seems specific for you project. |
Hi, Nope, we don't have any of those as dependencies. I just asked a question in StackOverflow in the hope that someone can enlighten us as to why those beans get instantiated. I've seen some of Michael Simons' and others' posts using only |
After further inspecting, I see that we do have |
Ok, we got it working. Apparently, To fix it, we just had to exclude it from our pom just like this:
Thank you @meistermeier for the clarification on how ReactiveNeo4jDataAutoConfiguration conditional instantiation works. Thanks to that we could solve this! |
@michael-simons I'm following your blogpost https://medium.com/neo4j/testing-your-neo4j-based-java-application-34bef487cc3c where you suggest use neo4j-harness The thing is, neo4j-harness depends on neo4j and neo4j depends on neo4j-fabric, which is bringing Reactor (Flux.class) What I just tried in the previous comments didn't seem to work after re-adding the embedded database to our IT tests. I thought that only excluding Reactor would work because it would be implemented just the way SDN is, separating imperative from reactive implementations but nope, here is a call to Hooks which belongs to Reactor project. Any suggestions appreciated |
Puh. You best bet is not using Harness, tbh. Testcontainers is the better choice. |
Woah, thanks for the quick answer. I'll take a look at it and see if it's possible to make the change. Last thing I remember we chose Harness over Testcontainers because the way our pipeline (Jenkins pipeline) is designed, it wouldn't allow us to spawn Docker containers inside it. |
Yeah, I hear you. That is sometimes an issue. I see the point to use an embedded instance… But I know the dependencies Neo4j (the database) comes with, and those are a lot. Could you try if setting this property (either globally in your app or in test, it's a Spring Boot property) helps in your case?
haven't gone through this whole issue here from top to bottom… |
This comment was marked as off-topic.
This comment was marked as off-topic.
Nope, it just fails while trying to instantiate ReactiveNeo4jTemplate :( |
Can you please share your setup? Config classes, and pom… Domain irrelevant. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I've created a Gist containing our pom.xml, a Base class for our IT tests that instantiates the embedded db, and the concrete IT class that has a simple test that fails before being executed It's basically a Spring Boot (2.4.13) + SDN (6.1.9) project, we don't make much apart from typical CRUD operations against Neo4j. https://gist.github.com/mrksph/84d095dc39628a59faab2e3d9eb0c68f |
So, indeed, Spring Boot does not let you disable the reactive clients config if Project reactor is on the classpath. This is their decision, but a decision I agree with. 2nd: It is indeed a bug on our side, but not a compatibility issue. I will fix this later this week. Here are two workaround in the meantime: a)
OR b)
|
null
) database selection.
This will btw only happen on the combination of SDN 6.1+ with Spring Boot 2.4. We fix this as a courtesy. |
Was just thinking about that as we are tied for now to Spring Boot 2.4 because compatibility with other Spring Cloud services we depend on. Thank you guys. Appreciate your work. |
You are welcome. Btw, as I can't find a release date for 6.1.x, 6.2.3 will also work with Boot 2.4 with a superficial check (your reproducer) and the workaround applied to imperative, too: @Configuration
public class FixInvalidConfigurationOfReactiveClient {
@Bean
public ReactiveNeo4jClient reactiveNeo4jClient(Driver driver,
ReactiveDatabaseSelectionProvider reactiveDatabaseSelectionProvider) {
return ReactiveNeo4jClient.create(driver, reactiveDatabaseSelectionProvider);
}
@Bean
public Neo4jClient neo4jClient(Driver driver,
DatabaseSelectionProvider databaseSelectionProvider) {
return Neo4jClient.create(driver, databaseSelectionProvider);
}
} at least in 6.2x we broke it consistently. Sorry about that, the area was in too much flux (no pun intended) since we developed that part. |
Awesome, thanks Michael! |
Hi,
I'm experiencing issues when upgrading SDN from 6.0.3 (included with spring-data-starter-neo4j 2.4.2) to 6.2.1 (either via dependencyManagement or direct dependency)
When I run the app I get the following error message:
The provided database selection provider differs from the Neo4jClient's one.
If I try to upgrade to 6.1.x instead I get
The provided database selection provider differs from the ReactiveNeo4jClient's one.
The text was updated successfully, but these errors were encountered: