<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=jmays" rel="nofollow">Joe Mays</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-2414?redirect=false" rel="nofollow">SPR-2414</a></strong> and commented</p>
<p dir="auto">If I enable debugging and start my app, I get the following NPE...  It looks like hashCode() in<br>
TransactionAttributeSourceAdvisor.TransactionAttributeSourcePointcut assumes that transactionInterceptor is always non-null...</p>
<p dir="auto">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<br>
Caused by:<br>
java.lang.NullPointerException<br>
at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.getTransactionAttributeSource(TransactionAttributeSourceAdvisor.java:102)<br>
at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.hashCode(TransactionAttributeSourceAdvisor.java:121)<br>
at java.lang.Object.toString(Object.java:209)<br>
at java.lang.String.valueOf(String.java:2577)<br>
at java.lang.StringBuffer.append(StringBuffer.java:220)<br>
at org.springframework.aop.support.AbstractPointcutAdvisor.toString(AbstractPointcutAdvisor.java:71)<br>
at java.lang.String.valueOf(String.java:2577)<br>
at java.lang.StringBuffer.append(StringBuffer.java:220)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:383)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:239)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:155)<br>
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:102)<br>
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:68)<br>
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:54)<br>
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:247)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:301)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:933)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:415)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:239)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:159)<br>
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:645)<br>
at org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:455)<br>
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:336)<br>
at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:92)<br>
at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:77)<br>
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)<br>
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)<br>
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)<br>
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)<br>
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:82)<br>
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:78)<br>
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:156)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:578)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:371)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:239)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:155)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:303)<br>
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)<br>
at org.springframework.context.access.ContextSingletonBeanFactoryLocator.initializeDefinition(ContextSingletonBeanFactoryLocator.java:136)<br>
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:380)<br>
at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:319)<br>
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:180)<br>
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)<br>
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669)</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0 RC3</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398069268" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/7102" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/7102/hovercard" href="https://github.com/spring-projects/spring-framework/issues/7102">#7102</a> NPE with TransactionAttributeSourceAdvisor.TransactionAttributeSourcePointcut when debug enabled (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto">1 votes, 1 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=chrislee" rel="nofollow">Chris Lee</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-2413?redirect=false" rel="nofollow">SPR-2413</a></strong> and commented</p>
<p dir="auto">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.</p>
<p dir="auto">This resulting in a NPE:</p>
<p dir="auto">java.lang.NullPointerException<br>
at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.getTransactionAttributeSource(TransactionAttributeSourceAdvisor.java:102)<br>
at org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor$TransactionAttributeSourcePointcut.hashCode(TransactionAttributeSourceAdvisor.java:121)<br>
at java.lang.Object.toString(Object.java:209)<br>
at java.lang.String.valueOf(String.java:2615)<br>
at java.lang.StringBuffer.append(StringBuffer.java:220)<br>
at org.springframework.aop.support.AbstractPointcutAdvisor.toString(AbstractPointcutAdvisor.java:71)<br>
at java.lang.String.valueOf(String.java:2615)<br>
at java.lang.StringBuffer.append(StringBuffer.java:220)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:383)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)</p>
<p dir="auto">...the bean that triggered this was:</p>
<p dir="auto">&lt;bean id="apTransactionAttributeSourceAdvisor"<br>
class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor"&gt;<br>
&lt;property name="transactionInterceptor" ref="apTxInterceptor" /&gt;<br>
&lt;property name="classFilter"&gt;<br>
&lt;bean class="org.springframework.aop.aspectj.TypePatternClassFilter"&gt;<br>
&lt;property name="typePattern" value="bridges.authPortal..*" /&gt;<br>
&lt;/bean&gt;<br>
&lt;/property&gt;<br>
&lt;/bean&gt;</p>
<p dir="auto">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).</p>
<p dir="auto">Possible solutions are to remove the hashCode (presumably it is there for a reason though) or add a toString() method to TransactionAttributeSourceAdvisor.TransactionAttributeSourcePointcut</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0 RC3</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398070047" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/7192" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/7192/hovercard" href="https://github.com/spring-projects/spring-framework/issues/7192">#7192</a> Change of logging level to debug causes bean creation failure in presence of tx:annotation-driven (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398069278" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/7103" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/7103/hovercard" href="https://github.com/spring-projects/spring-framework/issues/7103">#7103</a> NPE when creating a TransactionAttributeSourceAdvisor bean w/debug enabled (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398070130" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/7205" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/7205/hovercard" href="https://github.com/spring-projects/spring-framework/issues/7205">#7205</a> Bug with tx:annotation-driven/ and JPA with Spring 2 RC3: internal creation TransactionAttributeSourceAdvisor leads to NPE (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398070718" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/7277" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/7277/hovercard" href="https://github.com/spring-projects/spring-framework/issues/7277">#7277</a> Turning on debugging causes NPE with aspects (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">1 votes, 2 watchers</p>