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 (…)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s