Hibernate, Quick solutions, Spring Framework

How to solve: java.lang.IllegalArgumentException: Not an managed type

This is the first post of series “quick solutions”.

I have met issue mentioned in the topic in my current job. The reason occurred to be pretty simple. I have written wrong path in packagesToScan parameter of LocalContainerEntityManagerFactoryBean.

public EntityManagerFactory entityManagerFactory() throws PropertyVetoException {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

    return factory.getObject();

As a side note, Hibernate forces us to have default constructor (without params) in all managed entities, but exception is different then and looks more like the one I pasted below:

org.hibernate.InstantiationException: No default constructor for (…)