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

Repositories init fail #19

Closed
luxia7758 opened this issue Mar 2, 2022 · 12 comments · Fixed by #35
Closed

Repositories init fail #19

luxia7758 opened this issue Mar 2, 2022 · 12 comments · Fixed by #35
Assignees

Comments

@luxia7758
Copy link

I try to use it just like what /demos/roms-documents shows.

my redis-om version is 0.3.0-SNAPSHOT
and I use spring boot 2.6.3

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'teacherRepository' defined in com.xxxxxx.domain.repository.school.TeacherRepository defined in @EnableRedisDocumentRepositories declared on DemoAService: Unsatisfied dependency expressed through constructor parameter 1: Ambiguous argument values for parameter of type [com.redis.om.spring.ops.RedisModulesOperations] - did you specify the correct bean references as arguments?
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:787) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:1027) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:907) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:637) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:583) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:542) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:536) ~[spring-beans-5.3.14.jar:5.3.14]
at org.springdoc.core.SpringdocBeanFactoryConfigurer.initBeanFactoryPostProcessor(SpringdocBeanFactoryConfigurer.java:87) ~[springdoc-openapi-common-1.6.5.jar:1.6.5]
at org.springdoc.core.SpringdocBeanFactoryConfigurer.postProcessBeanFactory(SpringdocBeanFactoryConfigurer.java:78) ~[springdoc-openapi-common-1.6.5.jar:1.6.5]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:325) ~[spring-context-5.3.14.jar:5.3.14]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:198) ~[spring-context-5.3.14.jar:5.3.14]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.14.jar:5.3.14]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.14.jar:5.3.14]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar:2.6.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar:2.6.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar:2.6.3]
at com.mininglamp.tech.myai.pvt.traffic.DemoAService.main(DemoAService.java:15) ~[classes/:?]

Disconnected from the target VM, address: '127.0.0.1:64483', transport: 'socket'

Process finished with exit code 1

@bsbodden
Copy link
Contributor

bsbodden commented Mar 2, 2022

@luxia7758 here's a standalone working example with Document Repos. https://github.com/redis-developer/redis-om-spring-skeleton-app See if that works for you and then adjust yours to match. If your repo is public you can also point me to it and I can clone it and give it a try.

@bsbodden bsbodden self-assigned this Mar 6, 2022
@luxia7758
Copy link
Author

@luxia7758 here's a standalone working example with Document Repos. https://github.com/redis-developer/redis-om-spring-skeleton-app See if that works for you and then adjust yours to match. If your repo is public you can also point me to it and I can clone it and give it a try.

Thanks for your reply. I tried your url for redis-om-spring-skeleton-app, and it returns 404. I had just created a empty repo named redis-om-spring-demo and give you access. You are free to clone now.

@bsbodden
Copy link
Contributor

bsbodden commented Mar 9, 2022

@luxia7758 can you put a reproducer in that repo and I can investigate? Thanks!

@daveish
Copy link

daveish commented Apr 10, 2022

@bsbodden I have the same problem. This happens when I add spring-cloud-stream as dependency.
As soon as I remove the dependency, it works.

Here is a reproducer repo

@bsbodden
Copy link
Contributor

bsbodden commented Apr 10, 2022

@bsbodden I have the same problem. This happens when I add spring-cloud-stream as dependency. As soon as I remove the dependency, it works.

Here is a reproducer repo

Thanks for the reproducer, I started investigating "Spring Cloud Stream" with Redis (Spring Data Redis) and it seems the two projects aren't currently compatible, see:

I will investigate further since high-level Streams-support If one of the features we are planning

@daveish
Copy link

daveish commented Apr 10, 2022

@bsbodden You're welcome!
I imported spring-cloud-stream to use it with the kafka-binder btw., I had no intention of using the redis-binder.
The two dependencies (spring-cloud-stream and redis-om-spring) should not clash in my opinion.

I think the problem lies with the RedisDocumentRepositoryFactoryBean constructor. It states that the RedisModulesOperations parameter is ambiguous.

@bsbodden
Copy link
Contributor

@bsbodden You're welcome! I imported spring-cloud-stream to use it with the kafka-binder btw., I had no intention of using the redis-binder. The two dependencies (spring-cloud-stream and redis-om-spring) should not clash in my opinion.

I think the problem lies with the RedisDocumentRepositoryFactoryBean constructor. It states that the RedisModulesOperations parameter is ambiguous.

Can you do a quick test with just Spring Data Redis instead of Redis OM Spring, that might give us a clue. On the meantime I'll try to see if an explicit declaration of RedisModulesOperations does the trick.

@daveish
Copy link

daveish commented Apr 11, 2022

@bsbodden It works with spring-data-redis repositories, see additional reproducer.

@bsbodden
Copy link
Contributor

@bsbodden It works with spring-data-redis repositories, see additional reproducer.

No luck so far, tried a bunch of techniques to deal with ambiguity in the injection process but no luck so far. I'll make a new release as soon as I can find a solution.

@daveish
Copy link

daveish commented Apr 11, 2022

I made it work, I will submit a PR.

@bsbodden
Copy link
Contributor

Awesome! Thanks, David (@daveish) ! I will check the PR now.

@daveish
Copy link

daveish commented Apr 11, 2022

I opened another PR. I did some boy scouting while I was at it.

See #38

Cheers!

bsbodden pushed a commit that referenced this issue Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants