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

Error bootstrapping Spring Data JPA with EntityManagerFactory already semi-initialized [DATAJPA-1005] #1351

Closed
spring-projects-issues opened this issue Nov 17, 2016 · 6 comments
Assignees
Labels
in: core type: bug
Milestone

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Nov 17, 2016

Marc Vanbrabant opened DATAJPA-1005 and commented

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.Set<javax.persistence.EntityManager>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

We traced this back to the change in:
585ada9#diff-d3bc754b3e335bfa1ddeb79d4898f434R130

Could it be that the "else if" line on line 130 should be inside the first if, like so:

if (JNDI_OBJECT_FACTORY_BEAN.equals(definition.getBeanClassName())) {
     if (!EntityManagerFactory.class.getName().equals(definition.getPropertyValues().get("expectedType"))) {
          return;
     } else if (!EntityManagerFactory.class.equals(beanFactory.getType(name))) {
          return;
     }
}

I should also mention we do not use JNDI (object factories) and that under 1.10.2 this method does return a valid definition (the only change was lines 130 and 131 between 1.10.2 and 1.10.5).

Seems a regression from DATAJPA-956 ?


Affects: 1.10.5 (Hopper SR5)

Issue Links:

  • DATAJPA-1045 Error creating bean with name 'jpaContext'
    ("is duplicated by")

Referenced from: commits 0d6376d, 9c6a6a7, ba94c48

Backported to: 1.11 GA (Ingalls), 1.10.7 (Hopper SR7)

2 votes, 4 watchers

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jan 7, 2017

Arne Vandamme commented

Problem still exists with Athens-SR2 (JPA 1.10.6).
This causes the SharedEntityManager not be registered in the EntityManagerBeanDefinitionRegistrarPostProcessor

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jan 19, 2017

Oliver Drotbohm commented

Do you guys have an example project handy reproducing the issue? I just want to make sure I get the exact context this error occurs in

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jan 25, 2017

Oliver Drotbohm commented

Looking at it more closely I wonder what the call to beanFactory.getType(…) returns in your case then? The only thing I can imagine is a more concrete type being returned by the AbstractEntityManagerFactory. I'm gonna go ahead and relax the check to general assignability

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jan 25, 2017

Oliver Drotbohm commented

Fix is in place. See the commit message for details. I know it's probably too short notice but if you could give the snapshots a spin, that'd be awesome. We're shooting for a release (Ingalls GA) later today or early tomorrow

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jan 25, 2017

Arne Vandamme commented

Looks like this fixes it. Based on your commit comment, some more light to shed: the issue occurs in a multi ApplicationContext setup, so it might be a bean from a parent context that had been initialized already, so not a plain BeanDefinition. Don't remember all the details of when and how the issue turned up - and no time right now - but that's most likely related.

Didn't get a notification of your reply 6 days ago, sorry about that, otherwise I would have tried to provide your with a sample

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jan 25, 2017

Oliver Drotbohm commented

No worries, Arne. The hierarchy situation definitely explains the scenario as we're then already inspecting a BeanDefinition that has to have been initialized and thus returns the more concrete type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: bug
Projects
None yet
Development

No branches or pull requests

2 participants