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

TransactionalOperator is not configured in Data Neo4j #41275

Closed
hantsy opened this issue Jun 29, 2024 · 9 comments
Closed

TransactionalOperator is not configured in Data Neo4j #41275

hantsy opened this issue Jun 29, 2024 · 9 comments

Comments

@hantsy
Copy link

hantsy commented Jun 29, 2024

When upgraded to Spring Boot 3.3.1(from the build log, Spring Boot 3.3.0 worked), I got an exception when running PostRepositoryTest in my Spring Boot neo4j example which demos using Neo4j reactive template.

Check the build stack here: https://github.com/hantsy/spring-reactive-sample/actions/runs/9722916730/job/26837408667

java.lang.NullPointerException: Cannot invoke "org.springframework.transaction.reactive.TransactionalOperator.transactional
(reactor.core.publisher.Mono)" because "this.transactionalOperator" is null
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 29, 2024
@wilkinsona
Copy link
Member

I suspect this is due to #40953, the forward port of #40895. Can you please try defining a ReactiveNeo4jTransactionManager bean and see if that helps?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jun 30, 2024
@hantsy
Copy link
Author

hantsy commented Jun 30, 2024

Add a ReactiveNeo4jTransactionManager bean, and got new exception like this.

java.lang.IllegalStateException: Failed to retrieve PlatformTransactionManager 
for @Transactional test: [DefaultTestContext@54463380 testClass = com.example.demo.PostRepositoryTest, 

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jun 30, 2024
@hantsy
Copy link
Author

hantsy commented Jun 30, 2024

I have to define a ReactiveNeo4jTransactionManager bean and add @Transactional(NOT_SUPPORTED) on the tests to get the test passed(I have no sense of this).

@hantsy
Copy link
Author

hantsy commented Jun 30, 2024

I suspect this is due to #40953, the forward port of #40895. Can you please try defining a ReactiveNeo4jTransactionManager bean and see if that helps?

In the commit, the ReactiveNeo4jTransactionManager bean definition is removed.

I do not use @Transactional explicitly in my codes, the error is from reactive neo4j template I used here.

@wilkinsona
Copy link
Member

wilkinsona commented Jul 1, 2024

Please see the javadoc for @DataNeo4jTest where it says:

By default, tests annotated with @DataNeo4jTest are transactional with the usual test-related semantics (i.e. rollback by default). This feature is not supported with reactive access so this should be disabled by annotating the test class with @Transactional(propagation = Propagation.NOT_SUPPORTED)

This note has been there since Spring Boot 2.4 and was added in #23630. I believe it's still relevant as spring-projects/spring-framework#24226 to which it links is still open.

I suspect that this wasn't actually working properly in 3.3.0, it just wasn't throwing an exception to make the error obvious.

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jul 1, 2024
@hantsy
Copy link
Author

hantsy commented Jul 1, 2024

I suspect that this wasn't actually working properly in 3.3.0, it just wasn't throwing an exception to make the error obvious.

I am not sure about this. Originally my testing codes were annotated with a @Transactional(propagation = Propagation.NOT_SUPPORTED), but it was commented out at some time.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 1, 2024
@wilkinsona
Copy link
Member

Sorry, I'm not sure I understand.

Annotating the test with @Transactional(propagation = Propagation.NOT_SUPPORTED) is what's documented and recommended. If a failure didn't occur when it was commented out then my suspicion is that it still wasn't actually working properly, but it wasn't throwing an exception so it wasn't obvious. You certainly wouldn't have got the transaction management that you may have expected as there's no such support when using a reactive transaction manager.

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jul 5, 2024
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Jul 12, 2024
@spring-projects-issues
Copy link
Collaborator

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2024
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Jul 19, 2024
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

No branches or pull requests

3 participants