title: Error creating bean with name 'as' defined in class path resource
body: <p>I have a Account Business Service which in which i am coding my Business Requirements. And for that Business Service i have a Advice class of SecurityCheck</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.jlcindia.spring.bservices;
  
  public class AccountService {
      public void getBal() {
          System.out.println("Get bal is successfull");
      }
      public void myDeposit() {
          System.out.println("MY Deposit is successfull");
      }
      public void myWithdraw() throws Exception {
          System.out.println("WIthdraw begin");
          int i=0;
          if (i == 1){
              throw new InSufficientFundsException();
          }
          System.out.println("WIthdraw end");
      }
  
  }
  </code></pre>
  
  <p>The advice class is as follows:</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.jlcindia.spring.mservices;
  
  import org.aspectj.lang.ProceedingJoinPoint;
  import org.aspectj.lang.annotation.Around;
  import org.aspectj.lang.annotation.Aspect;
  import org.aspectj.lang.annotation.Before;
  import org.aspectj.lang.annotation.Pointcut;
  
  @Aspect
  public class SecurityService {
  
      @Pointcut(value="execution(* com.jlcindia.spring.bservices.AccountService.my*(..))")
      public void pc1(){}
      @Pointcut(value="execution(* com.jlcindia.spring.bservices.CustomerService.del*(..))")
      public void pc2(){}
  
      @Around("pc1() or pc2()")
      public void verifyUser(ProceedingJoinPoint pjp) throws Throwable{
          System.out.println("SS-verifyUser()-Begin");
          pjp.proceed();
          System.out.println("SS-verifyUser()-END");
      }
  }
  </code></pre>
  
  <p>I use <em>annotation-config.xml</em> file to configure the Business Service and Advice class as follows:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;bean id="as" class="com.jlcindia.spring.bservices.AccountService" /&gt;
  &lt;bean id="security" class="com.jlcindia.spring.mservices.SecurityService"/&gt;
  </code></pre>
  
  <p>Here is the code to test it:</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.jlcindia.spring.aop;
  
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  
  import com.jlcindia.spring.bservices.AccountService;
  
  public class Client {
      public static void main(String[] args) {
          ApplicationContext ctx = new ClassPathXmlApplicationContext("application-context.xml");
          AccountService ast = (AccountService)ctx.getBean("as");
          ast.myDeposit();
          ast.getBal();
          try{
              ast.myWithdraw();
          }catch(Exception e){
              System.out.println("***sorry****");
          }
      }
  }
  </code></pre>
  
  <p>When I am running my client code to test the services whether the advice is applying or not I am getting this exception;</p>
  
  <pre class="lang-none prettyprint-override"><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'as' defined in class path resource [application-context.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut pc1
  </code></pre>
  
  <p>The full stack trace is:</p>
  
  <pre class="lang-none prettyprint-override"><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'as' defined in class path resource [application-context.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut pc1
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      at com.jlcindia.spring.aop.Client.main(Client.java:11)
  Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut pc1
      at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:316)
      at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:195)
      at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:181)
      at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:162)
      at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
      at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
      at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
      at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
      at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
      at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
      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:407)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
      ... 11 more&lt;/h3&gt;
  </code></pre>
  
  <p>Please help to figure out why this error occuring while creating the bean 'as'(AccountService). I don't have much knowledge on AOP, i am learner now... so please i need a little help on this question. thank you for your patience to read this...</p>