maven with clover plugin compile error with Aspect/Pointcut

When I ran

mvn clean clover2:setup test clover2:aggregate clover2:clover

with my maven pom.xml I am getting this compile error

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compil
e (default) on project components: Compiler errors:
[ERROR] error at private void allPersistenceClasses() {try{__CLR3_3_036g36ghv6yg
jqe.R.inc(4129);

here is the PointCut method:

@Pointcut("execution(* com.foo.service..*.*(..))")
private void allPersistenceClasses() {

}


Any clue?

Thanks in advance.
-Wilson

3 answers

1 accepted

0 vote

Pointcuts without an if() expression should have an empty method body

This means that an AspectJ expects to see an empty method, which is not the case when Clover instrumentation is enabled. It's caused by a fact that Clover adds to such empty method a single statement calling the Clover's coverage recorder (in order to record a fact that method was entered).

In order to disable Clover instrumentation for such methods, you can surround them with ///CLOVER:OFF and ///CLOVER:ON keywords, e.g.:

///CLOVER:OFF
@Pointcut("execution(* com.foo.se.ws..*.*(..))")
private void allWebServiceClasses() {
}
///CLOVER:ON

Yes OFF/ON that did the trick. Thanks again

0 vote

Does the compile error description contain more lines? Could you paste a bigger log excerpt?

Here is the full compile error:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.754s
[INFO] Finished at: Thu May 15 07:34:07 EDT 2014
[INFO] Final Memory: 46M/110M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (default) on project components: Compiler errors:
[ERROR] error at private void allPersistenceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4129);
[ERROR]
[ERROR] C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:47:0::0 Pointcuts without an if() expression should have an empty method body
[ERROR] error at private void allServiceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4130);
[ERROR]
[ERROR] C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:51:0::0 Pointcuts without an if() expression should have an empty method body
[ERROR] error at private void allSEServiceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4131);
[ERROR]
[ERROR] C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:55:0::0 Pointcuts without an if() expression should have an empty method body
[ERROR] error at private void allWebServiceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4132);
[ERROR]
[ERROR] C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:60:0::0 Pointcuts without an if() expression should have an empty method body
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (default) on project components: Compiler errors:
error at private void allPersistenceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4129);

C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:47:0::0 Pointcuts without an if() expression should have an empty method body
error at private void allServiceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4130);

C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:51:0::0 Pointcuts without an if() expression should have an empty method body
error at private void allSEServiceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4131);

C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:55:0::0 Pointcuts without an if() expression should have an empty method body
error at private void allWebServiceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4132);

C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:60:0::0 Pointcuts without an if() expression should have an empty method body

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.codehaus.mojo.aspectj.CompilationFailedException: Compiler errors:
error at private void allPersistenceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4129);

C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:47:0::0 Pointcuts without an if() expression should have an empty method body
error at private void allServiceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4130);

C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:51:0::0 Pointcuts without an if() expression should have an empty method body
error at private void allSEServiceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4131);

C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:55:0::0 Pointcuts without an if() expression should have an empty method body
error at private void allWebServiceClasses() {try{__CLR3_3_036g36ghv7zbfyb.R.inc(4132);

C:\Users\user01\Workspaces\Release4\components\target\clover\src-instrumented\com\foo\se\component\service\LoggingAspect.java:60:0::0 Pointcuts without an if() expression should have an empty method body

at org.codehaus.mojo.aspectj.AbstractAjcCompiler.execute(AbstractAjcCompiler.java:411)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Here is the LoggingAspect.java

@Aspect
@Order(1)
@Configurable
public class LoggingAspect {
@Autowired
IMyLogger myLogger;

@Around("allPersistenceClasses() || allServiceClasses() || allSEServiceClasses() || allWebServiceClasses()")
public Object logError(ProceedingJoinPoint joinPoint) throws Throwable {

Object returnValue;

try {
returnValue = joinPoint.proceed();
} catch (Throwable throwable) {

myLogger.logInfo("Calling method {}" + joinPoint.getSignature().toLongString());
myLogger.logInfo("Arguments: {}" + Arrays.toString(joinPoint.getArgs()));
myLogger.logError(joinPoint.toLongString(), throwable);
throw throwable;
}
return returnValue;
}

@Pointcut("execution(* com.foo.jpa.service..*.*(..))")
private void allPersistenceClasses() {
}

@Pointcut("execution(* com.foo.component.services..*.*(..))")
private void allServiceClasses() {

}
@Pointcut("execution(* com.foo.se.service..*.*(..))")
private void allSEServiceClasses() {
}

@Pointcut("execution(* com.foo.se.ws..*.*(..))")
private void allWebServiceClasses() {
}

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published 5 hours ago in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

27 views 0 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you