title: maven bad class javax.annotation.PostConstruct
body: <p>I am trying to build a war project. and on compile it gives me this error: </p>
  
  <blockquote>
    <p>[compiler:compile] Compiling 432 source files to
    C:\Beta\ECORP5\ECORP5-web\target\classes
    ------------------------------------------------------------- COMPILATION ERROR : 
    ------------------------------------------------------------- \Beta\fin\fin-web\src\main\java\com\comp\fin\utils\Formatter.java:[23,-1]
    cannot access javax.annotation.PostConstruct bad class file:
    C:\Beta\fin\fin-web\target\endorsed\javaee-endorsed-api-6.0.jar(javax/annotation/PostConstruct.class)
    class file has wrong version 50.0, should be 49.0 1 error</p>
  </blockquote>
  
  <p>I am not able to get rid of this error. I am using java 6 and jdk 1.5 here is my POM.xml or part of it without unrelated stuff:</p>
  
  <pre><code>&gt; &lt;**?**xml version="1.0" encoding="UTF-8"?**&gt; &lt;**project
  &gt; xmlns="http://maven.apache.org/POM/4.0.0"
  &gt; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  &gt; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  &gt; http://maven.apache.org/xsd/maven-4.0.0.xsd"**&gt;
  &gt;     
  
  &gt;&lt;*modelVersion&gt;4.0.0&lt;*/modelVersion&gt;
  &gt;     &lt;*parent&gt;
  &gt;         &lt;*artifactId&gt;fin&lt;*/artifactId&gt;
  &gt;         &lt;*groupId&gt;com.comps&lt;*/groupId&gt;
  &gt;         &lt;*version&gt;1.0-SNAPSHOT&lt;*/version&gt;
  &gt;     &lt;*/parent&gt;
  &gt; 
  &gt;     &lt;groupId&gt;com.comps&lt;/groupId&gt;
  &gt;     &lt;artifactId&gt;fin-web&lt;/artifactId&gt;
  &gt;     &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &gt;     &lt;packaging&gt;war&lt;/packaging&gt;
  &gt; 
  &gt;     &lt;name&gt;fin-web&lt;/name&gt;
  &gt; 
  &gt;     &lt;properties&gt;
  &gt;         &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt;
  &gt;         &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
  &gt;     &lt;/properties&gt;
  &gt; 
  &gt;     &lt;dependencies&gt;
  &gt;        
  &gt;         &lt;dependency&gt;
  &gt;             &lt;groupId&gt;javax&lt;/groupId&gt;
  &gt;             &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
  &gt;             **&lt;version&gt;6.0&lt;/version&gt;**            
  &gt;         &lt;/dependency&gt;
  &gt; 
  &gt;     &lt;/dependencies&gt;
  &gt; 
  &gt;     &lt;build&gt;
  &gt;         &lt;plugins&gt;
  &gt;             &lt;plugin&gt;
  &gt;                 &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &gt;                 &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
  &gt;                 &lt;version&gt;2.3.2&lt;/version&gt;
  &gt;                 &lt;configuration&gt;
  &gt;                     &lt;**source&gt;1.5&lt;/source&gt;
  &gt;                     &lt;target&gt;1.5&lt;/target&gt;**
  &gt;                     &lt;compilerArguments&gt;
  &gt;                         &lt;endorseddirs&gt;${endorsed.dir}&lt;/endorseddirs&gt;
  &gt;                     &lt;/compilerArguments&gt;
  &gt;                 &lt;/configuration&gt;
  &gt;             &lt;/plugin&gt;
  &gt;             &lt;plugin&gt;
  &gt;                 &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &gt;                 &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
  &gt;                 &lt;version&gt;2.1.1&lt;/version&gt;
  &gt;                 &lt;configuration&gt;
  &gt;                     &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
  &gt;                 &lt;/configuration&gt;
  &gt;             &lt;/plugin&gt;
  &gt;             &lt;plugin&gt;
  &gt;                 &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &gt;                 &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
  &gt;                 &lt;version&gt;2.1&lt;/version&gt;
  &gt;                 &lt;executions&gt;
  &gt;                     &lt;execution&gt;
  &gt;                         &lt;phase&gt;validate&lt;/phase&gt;
  &gt;                         &lt;goals&gt;
  &gt;                             &lt;goal&gt;copy&lt;/goal&gt;
  &gt;                         &lt;/goals&gt;
  &gt;                         &lt;configuration&gt;
  &gt;                             &lt;outputDirectory&gt;${endorsed.dir}&lt;/outputDirectory&gt;
  &gt;                             &lt;silent&gt;true&lt;/silent&gt;
  &gt;                             &lt;artifactItems&gt;
  &gt;                                 &lt;artifactItem&gt;
  &gt;                                     &lt;groupId&gt;javax&lt;/groupId&gt;
  &gt;                                     &lt;artifactId&gt;javaee-endorsed-api&lt;/artifactId&gt;
  &gt;                                     &lt;version&gt;6.0&lt;/version&gt;
  &gt;                                     &lt;type&gt;jar&lt;/type&gt;
  &gt;                                 &lt;/artifactItem&gt;
  &gt;                             &lt;/artifactItems&gt;
  &gt;                         &lt;/configuration&gt;
  &gt;                     &lt;/execution&gt;
  &gt;                 &lt;/executions&gt;
  &gt;             &lt;/plugin&gt;
  &gt;         &lt;/plugins&gt;
  &gt;     &lt;/build&gt;
  &gt; 
  &gt; &lt;/project&gt;
  </code></pre>
  
  <p>I am using NetBeans IDE to create an ear project and this is the POM of the war module. I am building it separately. I dont think that should be a problem.</p>
  
  <p>I will appreciate if some one can tell me what is wrong here that it gives this error.</p>
  
  <p>On a side note: When I created the Maven Ear project it was using JavaEE 6 so the war module was also using Java EE 6 but when I added some files in the webApp directory of the war module the Java EE version changed in the war module properties to Java EE 1.4 I don't know how it is doing that and why or which file is making it change on module level.</p>