Nick Williams opened SPR-10856 and commented
This may be a Java-config problem only. I haven't tried it with XML config.
I'm configuring a LocalContainerEntityManagerFactoryBean, and I want to enable load time weaving. @EnableLoadTimeWeaving works (I see in the log that it found addTransformer on the ClassLoader and created a load time weaver), but setLoadTimeWeaver is never called on the LocalContainerEntityManagerFactoryBean.
LocalContainerEntityManagerFactoryBean implements LoadTimeWeaverAware, so my (possibly incorrect) assumption was that Spring should set the LoadTimeWeaver property, but it does not. If my assumption was incorrect, the documentation should be updated to indicate that you must call this method manually. If my assumption was correct, there is a bug here, because Spring is not calling this method.
Instead, I have to do this in my configuration:
@Configuration
...
@EnableLoadTimeWeaving
...
public class RootContextConfiguration
{
...
@Inject LoadTimeWeaver loadTimeWeaver;
...
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean()
{
...
LocalContainerEntityManagerFactoryBean factory =
new LocalContainerEntityManagerFactoryBean();
...
factory.setLoadTimeWeaver(this.loadTimeWeaver);
...
return factory;
}
...
}
That code works. The LoadTimeWeaver is injected and I successfully add it to my factory, then the JPA provider starts instrumenting my classes. However, without this the LoadTimeWeaver is never added to the LocalContainerEntityManagerFactoryBean and the JPA provider cannot instrument my classes.
Affects: 3.2.4, 4.0 M2
Issue Links:
Referenced from: commits 437ffa6
9 votes, 14 watchers
Nick Williams opened SPR-10856 and commented
This may be a Java-config problem only. I haven't tried it with XML config.
I'm configuring a
LocalContainerEntityManagerFactoryBean, and I want to enable load time weaving.@EnableLoadTimeWeavingworks (I see in the log that it foundaddTransformeron theClassLoaderand created a load time weaver), butsetLoadTimeWeaveris never called on theLocalContainerEntityManagerFactoryBean.LocalContainerEntityManagerFactoryBeanimplementsLoadTimeWeaverAware, so my (possibly incorrect) assumption was that Spring should set theLoadTimeWeaverproperty, but it does not. If my assumption was incorrect, the documentation should be updated to indicate that you must call this method manually. If my assumption was correct, there is a bug here, because Spring is not calling this method.Instead, I have to do this in my configuration:
That code works. The
LoadTimeWeaveris injected and I successfully add it to my factory, then the JPA provider starts instrumenting my classes. However, without this theLoadTimeWeaveris never added to theLocalContainerEntityManagerFactoryBeanand the JPA provider cannot instrument my classes.Affects: 3.2.4, 4.0 M2
Issue Links:
Referenced from: commits 437ffa6
9 votes, 14 watchers