Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17430

SpringBeanContainer for Hibernate 5 does not deal with NoSuchBeanDefinitionException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.1.1
    • Fix Version/s: 5.1.2
    • Component/s: Data:ORM
    • Labels:
      None

      Description

      Originally raised as a Spring Boot issue with a sample application.

      The fallback logic fixed in SPR-17010 works by catching BeanCreationException but unfortunately that doesn't seem to cover all cases. We probably need to additionally catch NoSuchBeanDefinitionException.

      The sample application provided throws the following stacktrace:

      java.lang.reflect.InvocationTargetException
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke (Method.java:566)
          at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:558)
          at java.lang.Thread.run (Thread.java:834)
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.search.exception.SearchException: HSEARCH000139: Unable to instantiate FieldBridge for uid of class java.util.UUID
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1745)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:576)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:498)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0 (AbstractBeanFactory.java:320)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:318)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
          at org.springframework.context.support.AbstractApplicationContext.getBean (AbstractApplicationContext.java:1083)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:853)
          at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:546)
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
          at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:771)
          at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:395)
          at org.springframework.boot.SpringApplication.run (SpringApplication.java:314)
          at config.Application.main (Application.java:46)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke (Method.java:566)
          at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:558)
          at java.lang.Thread.run (Thread.java:834)
      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.search.exception.SearchException: HSEARCH000139: Unable to instantiate FieldBridge for uid of class java.util.UUID
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory (AbstractEntityManagerFactoryBean.java:402)
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet (AbstractEntityManagerFactoryBean.java:377)
          at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet (LocalContainerEntityManagerFactoryBean.java:341)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1804)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1741)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:576)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:498)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0 (AbstractBeanFactory.java:320)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:318)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
          at org.springframework.context.support.AbstractApplicationContext.getBean (AbstractApplicationContext.java:1083)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:853)
          at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:546)
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
          at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:771)
          at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:395)
          at org.springframework.boot.SpringApplication.run (SpringApplication.java:314)
          at config.Application.main (Application.java:46)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke (Method.java:566)
          at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:558)
          at java.lang.Thread.run (Thread.java:834)
      Caused by: org.hibernate.search.exception.SearchException: HSEARCH000139: Unable to instantiate FieldBridge for uid of class java.util.UUID
          at org.hibernate.search.bridge.impl.BridgeFactory.createFieldBridgeFromAnnotation (BridgeFactory.java:400)
          at org.hibernate.search.bridge.impl.BridgeFactory.findExplicitFieldBridge (BridgeFactory.java:350)
          at org.hibernate.search.bridge.impl.BridgeFactory.buildFieldBridge (BridgeFactory.java:203)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.bindFieldAnnotation (AnnotationMetadataProvider.java:1335)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.checkForField (AnnotationMetadataProvider.java:1258)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeMemberLevelAnnotations (AnnotationMetadataProvider.java:1065)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass (AnnotationMetadataProvider.java:615)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.doGetTypeMetadataFor (AnnotationMetadataProvider.java:192)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor (AnnotationMetadataProvider.java:181)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor (AnnotationMetadataProvider.java:165)
          at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders (SearchIntegratorBuilder.java:445)
          at org.hibernate.search.spi.SearchIntegratorBuilder.createNewFactoryState (SearchIntegratorBuilder.java:244)
          at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory (SearchIntegratorBuilder.java:200)
          at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator (SearchIntegratorBuilder.java:128)
          at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.boot (HibernateSearchSessionFactoryObserver.java:127)
          at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated (HibernateSearchSessionFactoryObserver.java:94)
          at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated (SessionFactoryObserverChain.java:35)
          at org.hibernate.internal.SessionFactoryImpl.<init> (SessionFactoryImpl.java:372)
          at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build (SessionFactoryBuilderImpl.java:467)
          at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build (EntityManagerFactoryBuilderImpl.java:939)
          at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory (SpringHibernateJpaPersistenceProvider.java:57)
          at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory (LocalContainerEntityManagerFactoryBean.java:365)
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory (AbstractEntityManagerFactoryBean.java:390)
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet (AbstractEntityManagerFactoryBean.java:377)
          at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet (LocalContainerEntityManagerFactoryBean.java:341)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1804)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1741)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:576)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:498)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0 (AbstractBeanFactory.java:320)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:318)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
          at org.springframework.context.support.AbstractApplicationContext.getBean (AbstractApplicationContext.java:1083)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:853)
          at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:546)
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
          at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:771)
          at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:395)
          at org.springframework.boot.SpringApplication.run (SpringApplication.java:314)
          at config.Application.main (Application.java:46)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke (Method.java:566)
          at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:558)
          at java.lang.Thread.run (Thread.java:834)
      Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.locationguru.app.model.UUIDBridge' available
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean (DefaultListableBeanFactory.java:343)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean (DefaultListableBeanFactory.java:335)
          at org.springframework.orm.hibernate5.SpringBeanContainer.createBean (SpringBeanContainer.java:154)
          at org.springframework.orm.hibernate5.SpringBeanContainer.getBean (SpringBeanContainer.java:109)
          at org.hibernate.search.cfg.impl.HibernateOrmBeanContainerBeanResolver.resolve (HibernateOrmBeanContainerBeanResolver.java:63)
          at org.hibernate.search.engine.service.beanresolver.impl.ReflectionFallbackBeanResolver.resolve (ReflectionFallbackBeanResolver.java:40)
          at org.hibernate.search.bridge.impl.BridgeFactory.createFieldBridgeFromAnnotation (BridgeFactory.java:371)
          at org.hibernate.search.bridge.impl.BridgeFactory.findExplicitFieldBridge (BridgeFactory.java:350)
          at org.hibernate.search.bridge.impl.BridgeFactory.buildFieldBridge (BridgeFactory.java:203)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.bindFieldAnnotation (AnnotationMetadataProvider.java:1335)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.checkForField (AnnotationMetadataProvider.java:1258)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeMemberLevelAnnotations (AnnotationMetadataProvider.java:1065)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass (AnnotationMetadataProvider.java:615)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.doGetTypeMetadataFor (AnnotationMetadataProvider.java:192)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor (AnnotationMetadataProvider.java:181)
          at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor (AnnotationMetadataProvider.java:165)
          at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders (SearchIntegratorBuilder.java:445)
          at org.hibernate.search.spi.SearchIntegratorBuilder.createNewFactoryState (SearchIntegratorBuilder.java:244)
          at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory (SearchIntegratorBuilder.java:200)
          at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator (SearchIntegratorBuilder.java:128)
          at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.boot (HibernateSearchSessionFactoryObserver.java:127)
          at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated (HibernateSearchSessionFactoryObserver.java:94)
          at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated (SessionFactoryObserverChain.java:35)
          at org.hibernate.internal.SessionFactoryImpl.<init> (SessionFactoryImpl.java:372)
          at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build (SessionFactoryBuilderImpl.java:467)
          at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build (EntityManagerFactoryBuilderImpl.java:939)
          at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory (SpringHibernateJpaPersistenceProvider.java:57)
          at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory (LocalContainerEntityManagerFactoryBean.java:365)
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory (AbstractEntityManagerFactoryBean.java:390)
          at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet (AbstractEntityManagerFactoryBean.java:377)
          at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet (LocalContainerEntityManagerFactoryBean.java:341)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1804)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAutowireCapableBeanFactory.java:1741)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:576)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:498)
          at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0 (AbstractBeanFactory.java:320)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:318)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199)
          at org.springframework.context.support.AbstractApplicationContext.getBean (AbstractApplicationContext.java:1083)
          at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:853)
          at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:546)
          at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
          at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:771)
          at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:395)
          at org.springframework.boot.SpringApplication.run (SpringApplication.java:314)
          at config.Application.main (Application.java:46)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke (Method.java:566)
          at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:558)
          at java.lang.Thread.run (Thread.java:834)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              pwebb Phil Webb
              Last updater:
              Spring Issuemaster
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 37 weeks ago