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 creating DefaultJpaContext bean with a non-EntityManagerFactory JndiObjectFactoryBean defined via JavaConfig [DATAJPA-956] #1307

Closed
spring-projects-issues opened this issue Aug 25, 2016 · 6 comments
Assignees
Labels
in: core Issues in core support type: bug A general bug

Comments

@spring-projects-issues
Copy link

Abhishek Gupta opened DATAJPA-956 and commented

After upgrading to 1.10.2, the following exception occurs at startup.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.orm.jpa.SharedEntityManagerCreator#2': Unsatisfied dependency expressed through method 'createSharedEntityManager' parameter 0: Could not convert argument value of type [com.sun.proxy.$Proxy138] to required type [javax.persistence.EntityManagerFactory]: Failed to convert value of type [com.sun.proxy.$Proxy138 implementing javax.jms.QueueConnectionFactory,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy] to required type [javax.persistence.EntityManagerFactory]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.sun.proxy.$Proxy138 implementing javax.jms.QueueConnectionFactory,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised,org.springframework.core.DecoratingProxy] to required type [javax.persistence.EntityManagerFactory]: no matching editors or conversion strategy found
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1214)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1120)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1049)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1019)
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:776)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)

I think this is caused by EntityManagerBeanDefinitionRegistrarPostProcessor. It is trying to create a SharedEntityManagerCreator even for JndiObjectFactoryBeans which do not expose a EntityManagerFactory.

After looking at the code, it seems to be an effect of DATAJPA-813


Affects: 1.10.2 (Hopper SR2)

Backported to: 1.10.3 (Hopper SR3)

1 votes, 4 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

Scheduling a fix for the next bugfix release. In the meantime, declaring the JndiObjectFactoryBean instances in an XML file using the <jee:jndi-lookup /> namespace element and use the expected-type attribbute to explicitly communicate the object type that the JNDI lookup will produce. Unfortunately that type is not exposed on bean definitions declared via JavaConfig

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

The fix is in place, feel free to give the snapshots a try

@spring-projects-issues
Copy link
Author

sreekanth commented

Thanks Oliver, will try it and let you know in sometimes.
Update : have tried with latest 1.11.0.BUILD-SNAPSHOT and now the problem went away. Please let us know when bug fix version or 1.11 releases, thanks...

@spring-projects-issues
Copy link
Author

sreekanth commented

@Oliver, will it be releasing sooner ?

@spring-projects-issues
Copy link
Author

Marc Vanbrabant commented

Oliver Drotbohm is it possible that this change introduced a regression? See DATAJPA-1005

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

No branches or pull requests

2 participants