title: Compilation error for annotations in Java using maven-compiler-plugin 2.5.1 with java 1.8 and netbeans
body: <p>I'm newborn in writing anotations in Java. I was trying to write my own following this tutorial: <a href="http://programmaticallyspeaking.com/playing-with-java-annotation-processing.html" rel="nofollow">Playing with Java annotation processing</a></p>
  
  <p>I wrote everything like it is there, but during compilation I'm getting an error: </p>
  
  <pre><code>Bad service configuration file javax.annotation.processing.Processor Provider &lt;my class&gt; not found.
  </code></pre>
  
  <p>I'm using netbeans and maven with plugin maven-compiler-plugin v. 2.5.1. and java sources v.1.8.</p>
  
  <p>In my pom.xml file I have (like suggested in page) following code:</p>
  
  <pre><code>&lt;plugin&gt;
    &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
    &lt;version&gt;2.5.1&lt;/version&gt;
    &lt;configuration&gt;
      &lt;source&gt;1.8&lt;/source&gt;
      &lt;target&gt;1.8&lt;/target&gt;
      &lt;!-- Disable annotation processing for ourselves. --&gt;
      &lt;compilerArgument&gt;-proc:none&lt;/compilerArgument&gt;
    &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>My OS is Linux (leatest ubuntu) and maven is that one integrated in Netbeans. </p>
  
  <p>I was trying to google it, but nothing helped me. All tutorials were for older release of plugin and Java. I tried older release of maven-compiler-plugin but with no effect. I cannot switch to older version of java because of new features introduced in Java 8.</p>
  
  <p>Thanks a lot for any pointing me how to fix it. </p>
  
  <p><strong>Edit:</strong> </p>
  
  <p>Here is full list of my sources:</p>
  
  <p><strong>Config.java</strong></p>
  
  <pre><code>@Retention(RetentionPolicy.SOURCE)
  @Target(value = {ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER})
  public @interface Config {
      String name();
      String type();
      String defaultValue();
  }
  </code></pre>
  
  <p><strong>ConfigAnnotationProcessor.java</strong></p>
  
  <pre><code>@SupportedAnnotationTypes(
          {"sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotations"}
  )
  public class ConfigAnnotationProcessor extends AbstractProcessor {
  
      @Override
      public boolean process(Set&lt;? extends TypeElement&gt; annotations, RoundEnvironment env) {
          Messager messager = processingEnv.getMessager();
          annotations.stream().forEach((te) -&gt; {
              env.getElementsAnnotatedWith(te).stream().forEach((e) -&gt; {
                  messager.printMessage(Diagnostic.Kind.NOTE,
                          "Printing: " + e.toString());
              });
          });
          return true;
      }
  
      @Override
      public SourceVersion getSupportedSourceVersion() {
          return SourceVersion.latestSupported();
      }
  }
  </code></pre>
  
  <p><strong>META-INF/services/javax.annotation.processing.Processor</strong></p>
  
  <pre><code>sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor
  </code></pre>
  
  <p><strong>pom.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;sk.lieskove301.jianghongtiao&lt;/groupId&gt;
      &lt;artifactId&gt;MotionAnalyser&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;dependencies&gt;
          .... some dependencies ...
      &lt;/dependencies&gt;
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
          &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;/properties&gt;
      &lt;profiles&gt;
          &lt;profile&gt;
              &lt;build&gt;
                  &lt;plugins&gt;
                      &lt;plugin&gt;
                          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                          &lt;version&gt;2.5.1&lt;/version&gt;
                          &lt;configuration&gt;
                              &lt;source&gt;1.8&lt;/source&gt;
                              &lt;target&gt;1.8&lt;/target&gt;
                              &lt;!-- Disable annotation processing for ourselves.--&gt;
                              &lt;compilerArgument&gt;-proc:none&lt;/compilerArgument&gt; 
                          &lt;/configuration&gt;
                      &lt;/plugin&gt;
                  &lt;/plugins&gt;
              &lt;/build&gt;
          &lt;/profile&gt;
      &lt;/profiles&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>And this is <strong>log of my compiler</strong>:</p>
  
  <pre><code>cd /home/xjuraj/Dropbox/Work/MotionAnalyser; JAVA_HOME=/usr/lib/jvm/java-8-oracle /usr/local/netbeans-8.0/java/maven/bin/mvn clean install
  Scanning for projects...
  
  ------------------------------------------------------------------------
  Building MotionAnalyser 1.0-SNAPSHOT
  ------------------------------------------------------------------------
  
  --- maven-clean-plugin:2.4.1:clean (default-clean) @ MotionAnalyser ---
  Deleting /home/xjuraj/Dropbox/Work/MotionAnalyser/target
  
  --- maven-resources-plugin:2.5:resources (default-resources) @ MotionAnalyser ---
  [debug] execute contextualize
  Using 'UTF-8' encoding to copy filtered resources.
  Copying 6 resources
  
  --- maven-compiler-plugin:2.3.2:compile (default-compile) @ MotionAnalyser ---
  Compiling 27 source files to /home/xjuraj/Dropbox/Work/MotionAnalyser/target/classes
  -------------------------------------------------------------
  COMPILATION ERROR : 
  -------------------------------------------------------------
  error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
  1 error
  -------------------------------------------------------------
  ------------------------------------------------------------------------
  BUILD FAILURE
  ------------------------------------------------------------------------
  Total time: 1.661s
  Finished at: Mon Aug 11 19:56:16 CEST 2014
  Final Memory: 12M/180M
  ------------------------------------------------------------------------
  Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project MotionAnalyser: Compilation failure
  error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
  -&gt; [Help 1]
  
  To see the full stack trace of the errors, re-run Maven with the -e switch.
  Re-run Maven using the -X switch to enable full debug logging.
  
  For more information about the errors and possible solutions, please read the following articles:
  [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
  </code></pre>
  
  <p><strong>Edit 2 and so on...</strong>: </p>
  
  <p><a href="http://s30.postimg.org/xi1wm49jz/Screenshot_from_2014_08_13_18_08_26.png" rel="nofollow">Screenshot of my environment is here</a></p>
  
  <p><a href="http://s12.postimg.org/hjdj38rks/screenshot.jpg" rel="nofollow">Screenshot of my folder structure</a></p>
  
  <p><strong>Output of non-integrated maven</strong></p>
  
  <pre><code>xjuraj@xjuraj-pc:~/Dropbox/Work/MotionAnalyser$ mvn -e package
  + Error stacktraces are turned on.
  [INFO] Scanning for projects...
  [INFO] ------------------------------------------------------------------------
  [INFO] Building Unnamed - sk.lieskove301.jianghongtiao:MotionAnalyser:jar:1.0-SNAPSHOT
  [INFO]    task-segment: [package]
  [INFO] ------------------------------------------------------------------------
  [INFO] [resources:resources {execution: default-resources}]
  [INFO] Using 'UTF-8' encoding to copy filtered resources.
  [INFO] Copying 6 resources
  [INFO] [compiler:compile {execution: default-compile}]
  [INFO] Compiling 27 source files to /home/xjuraj/Dropbox/Work/MotionAnalyser/target/classes
  [INFO] -------------------------------------------------------------
  [ERROR] COMPILATION ERROR : 
  [INFO] -------------------------------------------------------------
  [ERROR] error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
  [INFO] 1 error
  [INFO] -------------------------------------------------------------
  [INFO] ------------------------------------------------------------------------
  [ERROR] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Compilation failure
  error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
  
  [INFO] ------------------------------------------------------------------------
  [INFO] Trace
  org.apache.maven.BuildFailureException: Compilation failure
  error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
  
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
      at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:483)
      at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
  Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
  error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
  
      at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729)
      at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
      ... 17 more
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 2 seconds
  [INFO] Finished at: Thu Aug 14 15:10:26 CEST 2014
  [INFO] Final Memory: 19M/187M
  [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p>Cheers, 
  juraj</p>