org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ajaxController': Unsatisfied dependency expressed through field 'apiService': Error creating bean with name 'apiService': Invocation of init method failed; nested exception is org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.sbjasperangular.model.Country.cities, could not initialize proxy - no Session; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apiService': Invocation of init method failed; nested exception is org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.sbjasperangular.model.Country.cities, could not initialize proxy - no Session

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,
via Stack Overflow by JamesENL

Use the proper ORM annotations (@ManyToOne and @OneToMany).

,
via Stack Overflow by Kleber Mota

Use eager fetch (fetch = FetchType.EAGER) annotation.

Solutions on the web

via GitHub by hidetarou2013
, 11 months ago
: failed to lazily initialize a collection of role: com.example.sbjasperangular.model.Country.cities, could not initialize proxy - no Session; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
via Coderanch by sam liya, 3 months ago
Error creating bean with name 'xxxxxServiceImpl': Unsatisfied dependency expressed through field 'xxxxxxRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxxxRepository
via Stack Overflow by karim hagui
, 4 months ago
Error creating bean with name 'scheduledTasks': Unsatisfied dependency expressed through field 'appRepo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'operationRepo': Invocation of init
via Stack Overflow by Shek
, 7 months ago
Error creating bean with name 'bookServiceImpl': Unsatisfied dependency expressed through field 'booksDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'booksDao': Invocation of init
via GitHub by kopax
, 11 months ago
resolve reference to bean 'sqlSessionFactory_Localism' while setting bean property 'localism'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory_Localism': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: not support database id: null
via Stack Overflow by HananeBmi1993
, 1 year ago
Error creating bean with name 'clientMetierImpl': Unsatisfied dependency expressed through field 'clientRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRepository
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.sbjasperangular.model.Country.cities, could not initialize proxy - no Session
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:587)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:204)
at org.hibernate.collection.internal.AbstractPersistentCollection.readElementExistence(AbstractPersistentCollection.java:316)
at com.example.sbjasperangular.model.Country.addCity(Country.java:43)
at com.example.sbjasperangular.service.ApiService.addCity(ApiService.java:40)
at com.example.sbjasperangular.service.ApiService.init(ApiService.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:310)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
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.doResolveDependency(DefaultListableBeanFactory.java:1054)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1019)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:566)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
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.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
at com.example.sbjasperangular.SbJasperAngularApplication2.main(SbJasperAngularApplication2.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)

Users with the same issue

22 times, 1 week ago
87 times, 2 weeks ago
Once, 4 weeks ago
12 times, 4 weeks ago
Once, 4 months ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.