Nested exception is Java.lang. Illegalargumentexception:error at:: 0 formal Unbound in pointcut

Source: Internet
Author: User
Tags aop throwable
Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' personservice ' defined in file [ L:\00.workspace\02.myeclipse
\springtextaop0118\webroot\web-inf\classes\com\lrk\bean\personservicebean.class]: Initialization of Bean failed; Nested exception is Java.lang.
Illegalargumentexception:error at:: 0 formal Unbound in pointcut
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:529)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:458)
At Org.springframework.beans.factory.support.abstractbeanfactory$1.getobject (abstractbeanfactory.java:296)
At Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:223)
At Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:293)
At Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:194)
At Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:628)
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.lrk.test.test.test (test.java:19)
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:25)
At Java.lang.reflect.Method.invoke (method.java:597)
At Org.junit.runners.model.frameworkmethod$1.runreflectivecall (frameworkmethod.java:44)
At Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:15)
At org.junit.runners.model.FrameworkMethod.invokeExplosively (frameworkmethod.java:41)
At Org.junit.internal.runners.statements.InvokeMethod.evaluate (invokemethod.java:20)
At Org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored (blockjunit4classrunner.java:79)
At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:71)
At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:49)
At Org.junit.runners.parentrunner$3.run (parentrunner.java:193)
At Org.junit.runners.parentrunner$1.schedule (parentrunner.java:52)
At Org.junit.runners.ParentRunner.runChildren (parentrunner.java:191)
At org.junit.runners.parentrunner.access$000 (parentrunner.java:42)
At Org.junit.runners.parentrunner$2.evaluate (parentrunner.java:184)
At Org.junit.internal.runners.statements.RunBefores.evaluate (runbefores.java:28)
At Org.junit.runners.ParentRunner.run (parentrunner.java:236)
At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:50)
At Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:467)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:683)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:390)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:197)
Caused by:java.lang.IllegalArgumentException:error at:: 0 formal Unbound in pointcut
At Org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression (pointcutparser.java:302)
At Org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression ( aspectjexpressionpointcut.java:209)
At Org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression ( aspectjexpressionpointcut.java:196)
At Org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch (Aspectjexpressionpointcut.java : 185)
At Org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter (aspectjexpressionpointcut.java:166)
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:409)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1518)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:521)


... Km






Error code: The reason is that the argument list was written in the predecessor notification but no argument was declared





package COM.EDUASK.AOP;
Import Org.aspectj.lang.ProceedingJoinPoint;
Import Org.aspectj.lang.annotation.After;
Import org.aspectj.lang.annotation.AfterReturning;
Import org.aspectj.lang.annotation.AfterThrowing;
Import Org.aspectj.lang.annotation.Around;
Import Org.aspectj.lang.annotation.Aspect;
Import Org.aspectj.lang.annotation.Before;
Import Org.aspectj.lang.annotation.Pointcut; /** * Section * */
@Component//declared as a component so that system startup will initialize the class
@Aspect//declared as a ASPECTJ slice public
class Myinterceptor {
	@Pointcut ("exe Cution (* com.eduask.aop. *.*(..))")
	private void Anymethod () {}//declares a pointcut
	
	@Before ("Anymethod ()") Public
	void Doaccesscheck (String name) {
		SYSTEM.OUT.PRINTLN ("Forward notification:" + name);
	}
	@AfterReturning (pointcut= "Anymethod ()", returning= "result") public
	void doafterreturning (String result) {
		System.out.println ("Post notice:" + result);
	}
	@After ("Anymethod ()") Public
	void Doafter () {
		System.out.println ("Final Notice");
	}
	@AfterThrowing (pointcut= "Anymethod ()", throwing= "E") public
	void doafterthrowing (Exception e) {
		SYSTEM.OUT.PRINTLN ("Exception Notice:" + E);
	}
	
	@Around ("Anymethod ()") Public
	Object dobasicprofiling (Proceedingjoinpoint pjp) throws Throwable {//if
		() {/ /Judge whether the user is in the right
		System.out.println ("Enter Method");
		Object result = Pjp.proceed ();
		System.out.println ("Exit Method");
		return result
	}
	
}
Correct code: You can remove the parameters in the predecessor notification or declare the parameter with args (), or the error







<pre name = "code" class = "java"> package com.lrk.test;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
/ **
 * Cut surface
 *
 * /
@Component // Declared as a component, so that the system startup will initialize the class
@Aspect // Declared as an AspectJ aspect
public class MyInterceptor {
The
@Pointcut ("execution (* com.lrk .. *. * (..))")
private void anyMethod () {} // Declare an entry point
The
@Before ("anyMethod () && args (args))")
public void doAccessCheck (Object args) {
System.out.println ("Advance notice:" + args);
}
@AfterReturning (pointcut = "anyMethod ()", returning = "result")
public void doAfterReturning (Object result) {
System.out.println ("Post notification:" + result);
}
@After ("anyMethod ()")
public void doAfter () {
System.out.println ("Final Notice");
}
@AfterThrowing (pointcut = "anyMethod ()", throwing = "e")
public void doAfterThrowing (Exception e) {
System.out.println ("Exception notice:" + e);
}
The
@Around ("anyMethod ()")
public Object doBasicProfiling (ProceedingJoinPoint pjp) throws Throwable {
// if () {// Determine whether the user is in the authority
System.out.println ("Enter Method");
Object result = pjp.proceed ();
System.out.println ("Exit Method");
//}
return result;
}
} 











Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.