aspose file tools*
The moose likes Spring and the fly likes SPRING AOP: error at ::0 can't find referenced pointcut Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "SPRING AOP: error at ::0 can Watch "SPRING AOP: error at ::0 can New topic
Forums: Spring Aspect Oriented Programming
Author

SPRING AOP: error at ::0 can't find referenced pointcut

Alessandro Minutello
Greenhorn

Joined: Apr 02, 2013
Posts: 1
Hi,
i read a lot of topics about this problem but i haven't solved yet... maybe i'm searching too far the solution.

I have the followings classes:

package com.aspects;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;


@Aspect
public class AspectModule {
@Pointcut("execution(* com.tutorialspoint.HelloWorld.*(..))")
private void selectAll(){
}

@Before("selectAll()")
public void printMessage() {
System.out.println("That's it!");
}


}


package com.tutorialspoint;

public class HelloWorld {


private String message;

public void setMessage(String message){
this.message = message;
}

public void getMessage(){
System.out.println("Your Message : " + message);
}
}


package com.tutorialspoint;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.prova.IHelloWorldService;



public class MainApp {

private static Log log = LogFactory.getLog(MainApp.class);

public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");

HelloWorld helloWorld = (HelloWorld) context.getBean("helloWorld");

log.info("Sto per mandare il messaggio!");

helloWorld.getMessage();

}
}


And the following XML

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">

<aop:aspectj-autoproxy />


<bean id="helloWorld" class="com.tutorialspoint.HelloWorld">
<property name="message" value="Ciao a tutti e buongiorno!"/>
</bean>

<bean id="AspectModule" class="com.aspects.AspectModule">
</bean>

</beans>


And i'm getting the following stacktrace:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorld' defined in class path resource [Beans.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut selectAll
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.tutorialspoint.MainApp.main(MainApp.java:17)
Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut selectAll
at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:315)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:208)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:194)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:183)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:164)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:208)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:262)
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:294)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:118)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:88)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:69)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:412)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1494)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
... 11 more


I've tryed everything but always the same error. If i comment the @Before there are no errors, but obviously nothing happens, if i de-comment it i have the error.

I have all the libraries updated... i'm beginning to think that it could be a code problem...

Any help?

My jars
aopalliance-1.0
asm-all-4.0_RC1
aspectj-1.7.2
aspectjrt
aspectjtools
aspectjweaver
cglib-2.2.0
org.aspectj.matcher
spring-framework-3.2.2.RELEASE
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1680
    
    7

You look to have extra dependencies I don't think you need. Its hard to read your code with all the colors, please UseCodeTags <- click on future posts.

Have a look at the POM file here and try to do the same.

http://kruders.com/spring/spring-aop-using-annotation-aspectj/


[How To Ask Questions][Read before you PM me]
Volodymyr Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

Hello!

As you are new to Spring I recommend you this tutorial
http://vrtoonjava.wordpress.com/2012/06/17/shall-we-do-some-spring-together/
and this one is very recent
http://vrtoonjava.wordpress.com/2013/03/03/spring-integration-developing-application-from-the-scratch-part-1-2/


True person is moral, false is right!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SPRING AOP: error at ::0 can't find referenced pointcut