When using bean profiles, all classes of all beans must be available whether or not the bean is activated as a result of the activation of the profile that it belongs to.
I discovered this by using a Maven profile to build a sample project that includes dependencies based on Maven profile(s). In my case, I'm switching between DataNucleus & Hibernate at build and test time. When the Maven profile for DataNucleus is activated, the DataNucleus dependencies are included; the Maven profile for Hibernate, the Hibernate dependencies.
In my application context config, I have a bean for a Hibernate & DataNucleus EMF:
Problem is, when the "dn" profile is active, the container throws an exception because the Hibernate dependencies are not available:
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/ejb/HibernatePersistence
If this profile is not activated, why should the bean classes mentioned in it need to be available?
Affects: 3.1 RC1
The text was updated successfully, but these errors were encountered:
Will need to look further, but at a glance, this certainly shouldn't be happening. Bean definitions are not registered at all if during parsing we notice an enclosing <beans profile="xyz"> element where 'xyz' is not currently active.
Can't repro with a small test project. Something else must've been going on. Go ahead and close this issue. I'll comment again if I figure out the juju to repro.
Matthew T. Adams opened SPR-8777 and commented
When using bean profiles, all classes of all beans must be available whether or not the bean is activated as a result of the activation of the profile that it belongs to.
I discovered this by using a Maven profile to build a sample project that includes dependencies based on Maven profile(s). In my case, I'm switching between DataNucleus & Hibernate at build and test time. When the Maven profile for DataNucleus is activated, the DataNucleus dependencies are included; the Maven profile for Hibernate, the Hibernate dependencies.
In my application context config, I have a bean for a Hibernate & DataNucleus EMF:
Problem is, when the "dn" profile is active, the container throws an exception because the Hibernate dependencies are not available:
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/ejb/HibernatePersistence
If this profile is not activated, why should the bean classes mentioned in it need to be available?
Affects: 3.1 RC1
The text was updated successfully, but these errors were encountered: