Hello all,
When trying to start up a spring project that contains a Spring AOP bean and transactionality with a data source plugged as a JNDI lookup, the following error is produced:
You can see the code that causes the problem in the attached zip file. It is essentially the Spring Tool Suite template simple MVC project with an AOP bean, a service bean, and transactionality for databases added, so as to duplicate the problem. The weird thing is that when I change the data source definition in the root-context.xml from:Code:... <wrapper exceptions trimmed> ... Caused by: java.lang.IllegalArgumentException: error can't bind type name 'com.koutra.test.TestAspect' at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301) [aspectjweaver-1.7.0.jar:1.7.0] at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.aspectj.AspectJExpressionPointcut.getFallbackPointcutExpression(AspectJExpressionPointcut.java:358) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:255) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:209) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:263) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:295) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322) [spring-aop-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1598) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:162) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE] ... 28 more
to:Code:<jee:jndi-lookup id="dataSource" jndi-name="java:jboss/datasources/protectDS" />
... all seems to be working. There is something going on with the combination of the AOP advice and the JNDI lookup of the datasource that seems to be causing the problem, but it is unclear to me what. I also tried googling for the problem, to no avail... Please provide any hints on what is going wrong here...Code:<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="username" value="root"/> <property name="password" value="z1g0u@l@"/> <property name="url" value="jdbc:mysql://localhost/test?zeroDateTimeBehavior=convertToNull"/> </bean>
I ended up writing by own version of the JndiObjectFactoryBean class that loads a one unique copy of the data source and using a bean of such concoction seems to be working, but I find it bizarre and unnatural, and I cannot believe that I am the only person that has tried Spring AOP beans with a data source that is looked up through JNDI, so I must be doing something basic wrong...
Thank you for your time. Kind regards,
Salagator
P.S. Here is the attachment:
test.zip


Reply With Quote