Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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 votes
Answer accepted

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 votes

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
TAGS
Community showcase
Published in Jira

Jira Cloud Performance Improvements

Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...

146 views 1 8
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you