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

[BUG] spring.factories is not published with final azure-spring-data-cosmos artifact #17651

Closed
3 tasks done
Blackbaud-EricSlater opened this issue Nov 18, 2020 · 2 comments · Fixed by #17682
Closed
3 tasks done
Assignees
Labels
azure-spring All azure-spring related issues azure-spring-cosmos Spring cosmos related issues. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@Blackbaud-EricSlater
Copy link
Contributor

Blackbaud-EricSlater commented Nov 18, 2020

Describe the bug
The spring.factories file that contains....
org.springframework.data.repository.core.support.RepositoryFactorySupport=com.azure.spring.data.cosmos.repository.support.CosmosRepositoryFactory
is not getting published with the azure-spring-data-cosmos artifact.

The main side effect of this that I have noticed is that the library does not work alongside other spring-data modules. In my case I was using it along side spring-data-jpa with a relational database. Not having this in place causes bean instantiation exceptions on startup. Spring has code internally that detects if multiple spring data modules are registered and it does this by seeing how many classes that extend RepositoryFactorySupport it has in the factories loader (CosmosRepositoryFactory extends RepositoryFactorySupport). Specifically this code...

boolean multipleModulesFound = SpringFactoriesLoader
      .loadFactoryNames(RepositoryFactorySupport.class, resourceLoader.getClassLoader()).size() > 1;

Without the spring.factories file in place, the above code does not detect CosmosRepositoryFactory and thinks spring-data-jpa is the only module registered. This sends spring down a different code path that only allows a single RepositoryFactoryBean instance to be instantiated instead of a RepositoryFactoryBean for each type of spring-data-module.

Exception or Stack Trace
The error that is raised when you try to use azure-spring-data-cosmos alongside another spring data module will look like this (in this case its used alongside spring-data-jpa)...

Cannot register bean definition [Root bean: class [org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean]

preceded by....

There is already [Root bean: class [com.azure.spring.data.cosmos.repository.support.CosmosRepositoryFactoryBean]

If the spring.factories file was in the artifact, spring would detect that multiple spring-data modules are registered and it would allow both of these beans to exist.

To Reproduce
Use azure-spring-data-cosmos alongside one other spring-data module like spring-data-jpa or spring-data-mongo

Expected behavior
The spring.factories file that already exists in the project here...
https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/cosmos/azure-spring-data-cosmos/src/main/resources/META-INF/spring.factories
should be published with the azure-spring-data-cosmos artifact

Workaround
Add the spring.factories file to your own project

Setup (please complete the following information):

  • OS: any
  • IDE : any
  • 3.1.0

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 18, 2020
@ghost
Copy link

ghost commented Nov 18, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kushagraThapar, @anfeldma-ms

@Blackbaud-EricSlater Blackbaud-EricSlater changed the title [BUG] spring.factories is not published with final spring-data-cosmos artifact [BUG] spring.factories is not published with final azure-spring-data-cosmos artifact Nov 18, 2020
@kushagraThapar
Copy link
Member

@mbhaskar - please take a look at this.

@joshfree joshfree added azure-spring All azure-spring related issues azure-spring-cosmos Spring cosmos related issues. Client This issue points to a problem in the data-plane of the library. labels Nov 18, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Nov 18, 2020
@saragluna saragluna linked a pull request Nov 19, 2020 that will close this issue
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
azure-spring All azure-spring related issues azure-spring-cosmos Spring cosmos related issues. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants