Antranig Basman opened SPR-3708 and commented

Spring currently generates exception traces which have text whose size will grow with the square of the bean fetch depth at which they occur - that is, since the "cause" exception message is printed out in full each time, each message includes the text at the next stack level which is a duplicate, and can become very hard to read. For example here is a message occuring at fetch depth 10:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TLABPostProcessorLoader' defined in class path resource [conf/rsf-config.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopeAlterationWrapperProxy' defined in class path resource [conf/rsf-config.xml]: Cannot create inner bean 'RSACBridgeProxy$child#9ffeb5' of type [uk.org.ponder.rsac.RSACBridgeProxy] while setting bean property 'value'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RSACBridgeProxy$child#9ffeb5' defined in class path resource [conf/rsf-config.xml]: Cannot resolve reference to bean 'RSACBeanLocator' while setting bean property 'RSACBeanLocator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RSACBeanLocator' defined in class path resource [conf/rsf-config.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'componentProcessorContributorParent$child' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFFixer' while setting bean property 'valueRef'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFFixer' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFRSFExecutor' while setting bean property 'executor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFRSFExecutor' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFExternalContext' while setting bean property 'externalContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFExternalContext' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFParameterMap' while setting bean property 'parameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFParameterMapInterpreter' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'requestMap' while setting bean property 'requestParameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopeAlterationWrapperProxy' defined in class path resource [conf/rsf-config.xml]: Cannot create inner bean 'RSACBridgeProxy$child#9ffeb5' of type [uk.org.ponder.rsac.RSACBridgeProxy] while setting bean property 'value'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RSACBridgeProxy$child#9ffeb5' defined in class path resource [conf/rsf-config.xml]: Cannot resolve reference to bean 'RSACBeanLocator' while setting bean property 'RSACBeanLocator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RSACBeanLocator' defined in class path resource [conf/rsf-config.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'componentProcessorContributorParent$child' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFFixer' while setting bean property 'valueRef'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFFixer' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFRSFExecutor' while setting bean property 'executor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFRSFExecutor' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFExternalContext' while setting bean property 'externalContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFExternalContext' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFParameterMap' while setting bean property 'parameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFParameterMapInterpreter' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'requestMap' while setting bean property 'requestParameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RSACBridgeProxy$child#9ffeb5' defined in class path resource [conf/rsf-config.xml]: Cannot resolve reference to bean 'RSACBeanLocator' while setting bean property 'RSACBeanLocator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RSACBeanLocator' defined in class path resource [conf/rsf-config.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'componentProcessorContributorParent$child' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFFixer' while setting bean property 'valueRef'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFFixer' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFRSFExecutor' while setting bean property 'executor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFRSFExecutor' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFExternalContext' while setting bean property 'externalContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFExternalContext' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFParameterMap' while setting bean property 'parameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFParameterMapInterpreter' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'requestMap' while setting bean property 'requestParameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RSACBeanLocator' defined in class path resource [conf/rsf-config.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'componentProcessorContributorParent$child' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFFixer' while setting bean property 'valueRef'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFFixer' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFRSFExecutor' while setting bean property 'executor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFRSFExecutor' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFExternalContext' while setting bean property 'externalContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFExternalContext' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFParameterMap' while setting bean property 'parameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFParameterMapInterpreter' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'requestMap' while setting bean property 'requestParameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'componentProcessorContributorParent$child' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFFixer' while setting bean property 'valueRef'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFFixer' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFRSFExecutor' while setting bean property 'executor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFRSFExecutor' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFExternalContext' while setting bean property 'externalContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFExternalContext' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFParameterMap' while setting bean property 'parameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFParameterMapInterpreter' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'requestMap' while setting bean property 'requestParameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFFixer' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFRSFExecutor' while setting bean property 'executor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFRSFExecutor' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFExternalContext' while setting bean property 'externalContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFExternalContext' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFParameterMap' while setting bean property 'parameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFParameterMapInterpreter' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'requestMap' while setting bean property 'requestParameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFRSFExecutor' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFExternalContext' while setting bean property 'externalContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFExternalContext' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFParameterMap' while setting bean property 'parameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFParameterMapInterpreter' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'requestMap' while setting bean property 'requestParameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFExternalContext' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'SWFParameterMap' while setting bean property 'parameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFParameterMapInterpreter' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'requestMap' while setting bean property 'requestParameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SWFParameterMapInterpreter' defined in class path resource [conf/rsf-swf-requestContext.xml]: Cannot resolve reference to bean 'requestMap' while setting bean property 'requestParameterMap'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'earlyRequestParser' defined in class path resource [conf/rsf-requestscope-config.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
Caused by: 
java.lang.NullPointerException
I   at uk.org.ponder.rsf.servlet.ServletEarlyRequestParser.init(ServletEarlyRequestParser.java:40)

In general the useful material is i) the message accumulated at the LEAST derived stack frame, and ii) the trace generated at the MOST derived stack frame.

The following SVN link to "UniversalRuntimeException" shows a possible implementation strategy and usage style for an Exception which produces more condensed messages, with only a single Exception object for a stack. Some of this code is devoted to conversion and unwrapping of checked exceptions and so is not directly relevant to this use case.

https://saffron.caret.cam.ac.uk/svn/projects/PonderUtilCore/trunk/src/uk/org/ponder/util/UniversalRuntimeException.java


Affects: 2.0.6

Issue Links: - #19175 OutOfMemoryError caused by nested UnsatisfiedDependencyExceptions - #12854 Overhaul core container error reporting

1 votes, 5 watchers

Comment From: spring-projects-issues

Marten Deinum commented

Also #19175 is related to this?

Comment From: NathanQingyangXu

Marten Deinum commented

Also #19175 is related to this?

It is indirectly related. This issue is about avoiding duplication in stack trace error reporting mechanism, the other ticket is more drastic to replace the stack trace with other mechanism.

Comment From: jhoeller

Superseded by #25162 which got addressed for 6.0 already.