@AfterThrowing#Throwing argument name 'ex' was not bound in advice arguments

576 views
Skip to first unread message

Enrico Goosen

unread,
Dec 3, 2008, 5:39:00 AM12/3/08
to CTJUG...@googlegroups.com

I started getting the above exception after altering the following class:

 

@Aspect

@Order(1)

public class LoggingExceptionAdvice {

      private static Logger logger = Logger.getLogger(LoggingExceptionAdvice.class);

      @AfterThrowing(pointcut="za.co.metcapri.common.aop.SystemPointCuts.inCapri()",throwing="ex")

      public void afterThrowing(Exception ex) throws Throwable {

            if (!(ex instanceof BusinessException)){

//                StringWriter stringWriter = new StringWriter();

//                PrintWriter printWriter = new PrintWriter(stringWriter, true);

//                ex.printStackTrace(printWriter);

//                printWriter.close();

//                logger.error(stringWriter.toString());

                  logger.error(ex);

            }

      }

}

 

The commented out code above is what caused this exception:

 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.TransactionInterceptor] while setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Cannot create inner bean 'org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter#4b084b08' of type [org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter] while setting bean property 'jpaVendorAdapter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter#4b084b08' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Advice configuration failed

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:228)

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:116)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1047)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:843)

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

       Truncated. see log file for complete stacktrace

org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Cannot create inner bean 'org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter#4b084b08' of type [org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter] while setting bean property 'jpaVendorAdapter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter#4b084b08' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Advice configuration failed

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:279)

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1047)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:843)

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

       Truncated. see log file for complete stacktrace

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Cannot create inner bean 'org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter#4b084b08' of type [org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter] while setting bean property 'jpaVendorAdapter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter#4b084b08' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Advice configuration failed

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:279)

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1047)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:843)

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

       Truncated. see log file for complete stacktrace

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Cannot create inner bean 'org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter#4b084b08' of type [org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter] while setting bean property 'jpaVendorAdapter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter#4b084b08' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Advice configuration failed

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:228)

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:111)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1047)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:843)

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

       Truncated. see log file for complete stacktrace

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter#4b084b08' defined in ServletContext resource [/WEB-INF/dataAccessJPAContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Advice configuration failed

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

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:221)

       at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:111)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1047)

       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:843)

       Truncated. see log file for complete stacktrace

java.lang.IllegalArgumentException: Advice configuration failed

       at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvice(ReflectiveAspectJAdvisorFactory.java:223)

       at org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl.instantiateAdvice(InstantiationModelAwarePointcutAdvisorImpl.java:145)

       at org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl.<init>(InstantiationModelAwarePointcutAdvisorImpl.java:94)

       at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvisor(ReflectiveAspectJAdvisorFactory.java:135)

       at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory$1.doWith(ReflectiveAspectJAdvisorFactory.java:75)

       Truncated. see log file for complete stacktrace

java.lang.IllegalStateException: Throwing argument name 'ex' was not bound in advice arguments

       at org.springframework.aop.aspectj.AbstractAspectJAdvice.bindExplicitArguments(AbstractAspectJAdvice.java:439)

       at org.springframework.aop.aspectj.AbstractAspectJAdvice.bindArgumentsByName(AbstractAspectJAdvice.java:381)

       at org.springframework.aop.aspectj.AbstractAspectJAdvice.calculateArgumentBindings(AbstractAspectJAdvice.java:350)

       at org.springframework.aop.aspectj.AbstractAspectJAdvice.afterPropertiesSet(AbstractAspectJAdvice.java:316)

       at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvice(ReflectiveAspectJAdvisorFactory.java:220)

       Truncated. see log file for complete stacktrace

 

Has anyone else experienced this?

 

PS. Added the commented out code, so that it would log the full stack trace instead of just the first line of the exception.

Strange thing is that the app runs fine on Tomcat 6, and even on my local Weblogic 9.2 server, but bombs out on the Development server (also Weblogic 9.2 running on AIX).

 

Regards,

 

Enrico Goosen

Software Developer

Metropolitan Employee Benefits

Email: EGoo...@metropolitan.co.za

Direct:  021 940 6231

Fax:      021 917 3089

Mobile:  083 305 5676

 

This message is subject to Metropolitans disclaimer pertaining to electronic communications. To view the disclaimer please visit http://www.metropolitan.co.za/disclaimer.asp

Brian Silberbauer

unread,
Dec 3, 2008, 6:24:43 AM12/3/08
to CTJUG...@googlegroups.com
Could this be related:

http://forum.springframework.org/showthread.php?t=62994

Conflicting jars would make sense if your servers are setup slightly
differently.

Brian
--
Brian Silberbauer Consulting

+27 (0)83 566 2705
http://www.gamatam.com/

jobs site: http://gamatamjobs.appspot.com/

James Mc Millan

unread,
Dec 3, 2008, 6:42:12 AM12/3/08
to CTJUG...@googlegroups.com
Alternatively you could try:

logger.error("Error trying to do something", ex);

Which will give you the full stack trace with log4j.

On Wed, Dec 3, 2008 at 12:39 PM, Enrico Goosen <EGoo...@metropolitan.co.za> wrote:

Enrico Goosen

unread,
Dec 3, 2008, 6:42:16 AM12/3/08
to CTJUG...@googlegroups.com
Which jars could be conflicting?
I haven't made any changes to my jars.
I only added those 5 lines of code to print the full stacktrace.
Perhaps I should wrap those 5 lines in a try catch block and see if its
throwing an IOException or something.

Very strange...


-----Original Message-----
From: CTJUG...@googlegroups.com [mailto:CTJUG...@googlegroups.com]
On Behalf Of Brian Silberbauer
Sent: 03 December 2008 01:25 PM
To: CTJUG...@googlegroups.com
Subject: [CTJUG Forum] Re: @AfterThrowing#Throwing argument name 'ex'
was not bound in advice arguments


Enrico Goosen

unread,
Dec 3, 2008, 7:08:45 AM12/3/08
to CTJUG...@googlegroups.com

Ha ha, ok cool.

 

From: CTJUG...@googlegroups.com [mailto:CTJUG...@googlegroups.com] On Behalf Of James Mc Millan


Sent: 03 December 2008 01:42 PM
To: CTJUG...@googlegroups.com

Johan Meyer

unread,
Dec 3, 2008, 7:33:14 AM12/3/08
to CTJUG...@googlegroups.com
hallo all
I am struggeling to setup tomcat. We have alot of different domain names linked to our tomcat server and I am trying to find a way to redirect them to the relevlent projects.
 
Here is an example of what I am trying to do:
 
domains:
www.x.com  should go to webApps/x
www.y.com  should go to webApps/y
www.z.com  should go to webApps/z
 
(x, y, z are the different webapps running on our server)
 
Our tomcat server is running on port 80 and we are running tomcat 5.5 on Ubuntu.
 
I did some googling and reading and found that I should add the following to the server.xml of tomcat.
<!-- This Host is the first "Virtual Host": www.example.com -->
      <Host name="www.example.com" appBase="/home/example/webapp">
        <Context path="" docBase="."/>
      </Host>
 
here is an example of what I added
      <Host name="www.x.com" appBase="/var/tomcat/webApps/x">
        <Context path="" docBase="."/>
      </Host>
 
But I did add it and still nothing worked. Please if anyone could let me know what I am doing wrong or what the solution to my problem is I would really appriciate it.
 
regards
Johan
 

David Tinker

unread,
Dec 3, 2008, 8:16:42 AM12/3/08
to CTJUG...@googlegroups.com
I cannot answer your question exactly but we use Apache web server,
virtual hosts and mod_jk to achieve the same result. This has the
added advantage that you can have different web apps hosted in
different instances of Tomcat (i.e. Java virtual machines) so they
cannot interfere with each other etc etc.

Cheers
David
--
http://www.simunlock.co.za

Martin Gross, EVOLT

unread,
Dec 3, 2008, 10:26:42 AM12/3/08
to CTJUG...@googlegroups.com
Hi Johan,

have a look at http://ex-parrot.com/~pete/tomcat-vhost.html . It
describes it quite in detail.

regards,
martin

OkaMthembo

unread,
Dec 3, 2008, 10:36:33 AM12/3/08
to CTJUG...@googlegroups.com
Hi Johan,

From your example, it appears to me as if the Virtual Host name tag should contain the server on which your Tomcat server is running, not any one of the sites you are trying to forward requests to.

Regards
Lloyd

On Wed, Dec 3, 2008 at 2:33 PM, Johan Meyer <in...@08mobile.com> wrote:



--
Lloyd Dube

Johan Meyer

unread,
Dec 3, 2008, 1:31:31 PM12/3/08
to CTJUG...@googlegroups.com
THANKS A LOT!! This is an excellent article

-----Original Message-----
From: CTJUG...@googlegroups.com [mailto:CTJUG...@googlegroups.com] On
Behalf Of Martin Gross, EVOLT
Sent: 03 December 2008 05:27 PM
To: CTJUG...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages