Issue 1:
Joe Mays opened SPR-2414 and commented

If I enable debugging and start my app, I get the following NPE... It looks like hashCode() in

TransactionAttributeSourceAdvisor.TransactionAttributeSourcePointcut assumes that transactionInterceptor is always non-null...

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor' defined in class path resource [businessContext.xml]: Instantiation of bean failed; nested exception is java.lang.NullPointerException

Caused by:

java.lang.NullPointerException

at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.getTransactionAttributeSource(TransactionAttributeSourceAdvisor.java:102)

at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.hashCode(TransactionAttributeSourceAdvisor.java:121)

at java.lang.Object.toString(Object.java:209)

at java.lang.String.valueOf(String.java:2577)

at java.lang.StringBuffer.append(StringBuffer.java:220)

at org.springframework.aop.support.AbstractPointcutAdvisor.toString(AbstractPointcutAdvisor.java:71)

at java.lang.String.valueOf(String.java:2577)

at java.lang.StringBuffer.append(StringBuffer.java:220)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:383)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:239)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:155)

at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:102)

at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:68)

at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:54)

at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:247)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:301)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:933)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:415)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:239)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:159)

at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:645)

at org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:455)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:336)

at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)

at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:494)

at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:82)

at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:78)

at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:156)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:578)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:371)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:239)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:155)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:303)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)

at org.springframework.context.access.ContextSingletonBeanFactoryLocator.initializeDefinition(ContextSingletonBeanFactoryLocator.java:136)

at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:380)

at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:319)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:180)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669)

Affects: 2.0 RC3

Issue Links:

#7102 NPE with TransactionAttributeSourceAdvisor.TransactionAttributeSourcePointcut when debug enabled ("duplicates")

1 votes, 1 watchers

Issue 2:
Chris Lee opened SPR-2413 and commented

Upgrading from 2.0RC2 to 2.0RC3; aside from a couple of moved classes, everything went smooth, until we turned on DEBUG for org.springframework.

This resulting in a NPE:

java.lang.NullPointerException

at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.getTransactionAttributeSource(TransactionAttributeSourceAdvisor.java:102)

at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.hashCode(TransactionAttributeSourceAdvisor.java:121)

at java.lang.Object.toString(Object.java:209)

at java.lang.String.valueOf(String.java:2615)

at java.lang.StringBuffer.append(StringBuffer.java:220)

at org.springframework.aop.support.AbstractPointcutAdvisor.toString(AbstractPointcutAdvisor.java:71)

at java.lang.String.valueOf(String.java:2615)

at java.lang.StringBuffer.append(StringBuffer.java:220)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:383)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)

...the bean that triggered this was:

<bean id="apTransactionAttributeSourceAdvisor"

class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">

<property name="transactionInterceptor" ref="apTxInterceptor" />

<property name="classFilter">

<bean class="org.springframework.aop.aspectj.TypePatternClassFilter">

<property name="typePattern" value="bridges.authPortal..*" />

</bean>

</property>

</bean>

It looks like AbstractAutowireCapableBeanFactory logs a debug message (line 383) "Eagerly caching...", which forces a toString on the instantiated bean; since the TransactionAttributeSourceAdvisor.TransactionAttributeSourcePointcut does not have a toString() method, it uses Object.toString, which calls hashCode(), triggering the NPE (as the interceptor hasn't been injected yet).

Possible solutions are to remove the hashCode (presumably it is there for a reason though) or add a toString() method to TransactionAttributeSourceAdvisor.TransactionAttributeSourcePointcut

Affects: 2.0 RC3

Issue Links:

#7192 Change of logging level to debug causes bean creation failure in presence of tx:annotation-driven ("is duplicated by")

#7103 NPE when creating a TransactionAttributeSourceAdvisor bean w/debug enabled ("is duplicated by")

#7205 Bug with tx:annotation-driven/ and JPA with Spring 2 RC3: internal creation TransactionAttributeSourceAdvisor leads to NPE ("is duplicated by")

#7277 Turning on debugging causes NPE with aspects ("is duplicated by")

1 votes, 2 watchers