# Error creating bean with name ‘entityManagerFactory’ defined in class path resource

**URL:** <https://discourse.hibernate.org/t/error-creating-bean-with-name-entitymanagerfactory-defined-in-class-path-resource/4675>\
**Category:** Hibernate Search\
**Created:** [October 20, 2020, 5:36am UTC](https://discourse.hibernate.org/t/error-creating-bean-with-name-entitymanagerfactory-defined-in-class-path-resource/4675 "2020-10-20T05:36:09Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![schoppara](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@schoppara](https://discourse.hibernate.org/u/schoppara)\
**Post date:** [October 20, 2020, 6:54am UTC](https://discourse.hibernate.org/t/error-creating-bean-with-name-entitymanagerfactory-defined-in-class-path-resource/4675/2 "2020-10-20T06:54:00Z")

</div>

Resolved this error by adding a Bean to the main application class.  
@Bean(name=“entityManagerFactory”)  
public LocalSessionFactoryBean sessionFactory() {  
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();  
return sessionFactory;  
}

---

_[View the full topic](https://discourse.hibernate.org/t/error-creating-bean-with-name-entitymanagerfactory-defined-in-class-path-resource/4675)._
