title: NetBeans - Maven - JaCoCo - Can't add different class with same name
body: <p>I'm just going to start this off with the links I have already checked:</p>
  <blockquote>
  <p><a href="https://stackoverflow.com/questions/61781578/jacoco-illegalstateexception-cant-add-different-class-with-same-name">Jacoco: IllegalStateException: Can&#39;t add different class with same name</a></p>
  <p><a href="https://stackoverflow.com/questions/50163426/jacoco-cannot-exclude-classes">jacoco : Cannot exclude classes</a></p>
  <p><a href="https://stackoverflow.com/questions/9133116/jacoco-test-coverage-how-to-exclude-a-class-inside-jar-from-report">JaCoCo test coverage: How to exclude a class inside jar from report?</a></p>
  <p><a href="https://stackoverflow.com/questions/11673356/jacoco-cant-add-different-class-with-same-name-org-hamcrest-basedescription">JaCoCo Can&#39;t add different class with same name: org/hamcrest/BaseDescription</a></p>
  </blockquote>
  <p>These are just the SO questions I have checked, not to mention all the GitHub posts too..</p>
  <p>I have spent 2 full days now trying to find the solution for <em>my</em> problem, but I have yet to find anything that works.</p>
  <p>So the story goes like this:</p>
  <ol>
  <li>NetBeans project for automation testing</li>
  <li>The company I work for has a jar file</li>
  <li>I used below command to include this jar file in my project:</li>
  </ol>
  <pre><code>    mvn install:install-file - 
      Dfile=C:\MavenSelenium\Automation_Framework\src\main\resources\Dependencies\java-api-1.0-jar-with- 
      dependencies.jar -DgroupId=this.jar.file -DartifactId=api-bundle -Dversion=1.0 -Dpackaging=jar
  </code></pre>
  <ol start="4">
  <li>Added the dependency to the <strong>pom.xml</strong> file</li>
  </ol>
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;this.jar.file&lt;/groupId&gt;
          &lt;artifactId&gt;api-bundle&lt;/artifactId&gt;
          &lt;version&gt;1.0&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  <ol start="5">
  <li>Open CMD, go to the location of the NetBeans project</li>
  <li>Execute the following maven command (Or Clean and Build Project in NetBeans):</li>
  </ol>
  <pre><code>    mvn clean verify
  </code></pre>
  <ol start="7">
  <li>Everything goes fine, EXCEPT when JaCoCo tries to generate the report. Below is the error log:</li>
  </ol>
  <pre><code>[INFO] --- jacoco-maven-plugin:0.8.6:report (report) @ Automation_Framework ---
  [INFO] Loading execution data file C:\MavenSelenium\Automation_Framework\target\jacoco.exec
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time:  18.851 s
  [INFO] Finished at: 2020-12-20T20:35:00+02:00
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.6:report (report) on project Automation_Framework: 
  An error has occurred in JaCoCo report generation.: Error while creating report: Error while analyzing 
  
  C:\MavenSelenium\Automation_Framework\target\classes\Dependencies\
  java-api-1.0-jar-with-dependencies.jar@org/apache/logging/log4j/core/util/SystemClock.class. 
  
  Can't add different class with same name: org/apache/logging/log4j/core/util/SystemClock -&gt; [Help 1]
  
  [ERROR]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [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
  </code></pre>
  <ol start="8">
  <li><p>The JAR file that is mentioned in the error above is the JAR file/dependency from my company</p>
  </li>
  <li><p>This is my pom.xml file:</p>
  </li>
  </ol>
  <pre><code>        &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; 
          &lt;groupId&gt;Automation_Framework&lt;/groupId&gt; 
          &lt;artifactId&gt;Automation_Framework&lt;/artifactId&gt; 
          &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; 
          &lt;packaging&gt;jar&lt;/packaging&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;dependencies&gt;
               
              &lt;!-- TestNG --&gt; 
              &lt;dependency&gt;
                  &lt;groupId&gt;org.testng&lt;/groupId&gt;
                  &lt;artifactId&gt;testng&lt;/artifactId&gt;
                  &lt;version&gt;7.3.0&lt;/version&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
       
              &lt;!-- Selenium Java --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
                  &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;
                  &lt;version&gt;3.141.59&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Selenium API --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
                  &lt;artifactId&gt;selenium-api&lt;/artifactId&gt;
                  &lt;version&gt;3.141.59&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Selenium Remote Driver --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
                  &lt;artifactId&gt;selenium-remote-driver&lt;/artifactId&gt;
                  &lt;version&gt;3.141.59&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Selenium Chrome Driver --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
                  &lt;artifactId&gt;selenium-chrome-driver&lt;/artifactId&gt;
                  &lt;version&gt;3.141.59&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Selenium Common --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
                  &lt;artifactId&gt;selenium-common&lt;/artifactId&gt;
                  &lt;version&gt;2.0b1&lt;/version&gt;
              &lt;/dependency&gt;
        
              &lt;!-- Apache Commons Lang3 --&gt; 
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
                  &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
                  &lt;version&gt;3.11&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Video Recorder --&gt; 
              &lt;dependency&gt;
                  &lt;groupId&gt;com.automation-remarks&lt;/groupId&gt;
                  &lt;artifactId&gt;video-recorder&lt;/artifactId&gt;
                  &lt;version&gt;1.0&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Apache POI --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
                  &lt;artifactId&gt;poi&lt;/artifactId&gt;
                  &lt;version&gt;4.1.2&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Apache POI OOXML--&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
                  &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
                  &lt;version&gt;4.1.2&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- JCraft --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;com.jcraft&lt;/groupId&gt;
                  &lt;artifactId&gt;jsch&lt;/artifactId&gt;
                  &lt;version&gt;0.1.55&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Extent - RX Java --&gt;
              &lt;dependency&gt;
                      &lt;groupId&gt;io.reactivex.rxjava3&lt;/groupId&gt;
                      &lt;artifactId&gt;rxjava&lt;/artifactId&gt;
                      &lt;version&gt;3.0.4&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Extent - Free Marker --&gt;
              &lt;dependency&gt;
                      &lt;groupId&gt;org.freemarker&lt;/groupId&gt;
                      &lt;artifactId&gt;freemarker&lt;/artifactId&gt;
                      &lt;version&gt;2.3.30&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Extent - Lombok --&gt;
              &lt;dependency&gt;
                      &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
                      &lt;artifactId&gt;lombok&lt;/artifactId&gt;
                      &lt;version&gt;1.18.12&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Extent - GSON --&gt;
              &lt;dependency&gt;
                      &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
                      &lt;artifactId&gt;gson&lt;/artifactId&gt;
                      &lt;version&gt;2.8.6&lt;/version&gt;
              &lt;/dependency&gt;
      
              &lt;!-- Apache JMeter Core --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.jmeter&lt;/groupId&gt;
                  &lt;artifactId&gt;ApacheJMeter_core&lt;/artifactId&gt;
                  &lt;version&gt;5.4&lt;/version&gt;
              &lt;/dependency&gt;
      
              &lt;!-- Apache JMeter Components --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.jmeter&lt;/groupId&gt;
                  &lt;artifactId&gt;ApacheJMeter_components&lt;/artifactId&gt;
                  &lt;version&gt;5.4&lt;/version&gt;
              &lt;/dependency&gt;
      
              &lt;!-- Apache JMeter JOrphan --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.jmeter&lt;/groupId&gt;
                  &lt;artifactId&gt;jorphan&lt;/artifactId&gt;
                  &lt;version&gt;5.4&lt;/version&gt;
              &lt;/dependency&gt;
      
              &lt;!-- Apache JMeter JUnit --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.jmeter&lt;/groupId&gt;
                  &lt;artifactId&gt;ApacheJMeter_junit&lt;/artifactId&gt;
                  &lt;version&gt;5.4&lt;/version&gt;
              &lt;/dependency&gt;
      
              &lt;!-- Apache JMeter HTTP --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.jmeter&lt;/groupId&gt;
                  &lt;artifactId&gt;ApacheJMeter_http&lt;/artifactId&gt;
                  &lt;version&gt;5.4&lt;/version&gt;
              &lt;/dependency&gt;
      
              &lt;!-- Apache HTTP Core --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
                  &lt;artifactId&gt;httpcore&lt;/artifactId&gt;
                  &lt;version&gt;4.4.14&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- XStream Core --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;com.thoughtworks.xstream&lt;/groupId&gt;
                  &lt;artifactId&gt;xstream&lt;/artifactId&gt;
                  &lt;version&gt;1.4.15&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Aerogear OTP --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.jboss.aerogear&lt;/groupId&gt;
                  &lt;artifactId&gt;aerogear-otp-java&lt;/artifactId&gt;
                  &lt;version&gt;1.0.0&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Appium Java Client --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;io.appium&lt;/groupId&gt;
                  &lt;artifactId&gt;java-client&lt;/artifactId&gt;
                  &lt;version&gt;7.4.1&lt;/version&gt;
              &lt;/dependency&gt;
              
              &lt;!-- Company Jar (API) --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;this.jar.file&lt;/groupId&gt;
                  &lt;artifactId&gt;api-bundle&lt;/artifactId&gt;
                  &lt;version&gt;1.0&lt;/version&gt;
                  &lt;scope&gt;compile&lt;/scope&gt;
                  &lt;exclusions&gt;
                    &lt;exclusion&gt;  &lt;!-- declare the exclusion here --&gt;
                      &lt;groupId&gt;this.jar.file&lt;/groupId&gt;
                      &lt;artifactId&gt;api-bundle&lt;/artifactId&gt;
                    &lt;/exclusion&gt;
                  &lt;/exclusions&gt; 
              &lt;/dependency&gt;
              
              &lt;!-- Surefire Plugin --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.0.0-M5&lt;/version&gt;
              &lt;/dependency&gt;
      
      
          &lt;/dependencies&gt;
          
          &lt;!-- Extent - Maven Checkstyle Plugin --&gt;
          &lt;reporting&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-checkstyle-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.16&lt;/version&gt;
                      &lt;reportSets&gt;
                          &lt;reportSet&gt;
                              &lt;reports&gt;
                                  &lt;report&gt;checkstyle&lt;/report&gt;
                              &lt;/reports&gt;
                          &lt;/reportSet&gt;
                      &lt;/reportSets&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/reporting&gt;
          
          &lt;build&gt;
              &lt;sourceDirectory&gt;src/main/java&lt;/sourceDirectory&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.3.1&lt;/version&gt;
                      &lt;executions&gt;
                        &lt;execution&gt;
                          &lt;id&gt;default-jar&lt;/id&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;goals&gt;
                            &lt;goal&gt;jar&lt;/goal&gt;
                          &lt;/goals&gt;
                        &lt;/execution&gt;
                      &lt;/executions&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                      &lt;version&gt;3.6.1&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;source&gt;1.8&lt;/source&gt;
                          &lt;target&gt;1.8&lt;/target&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
                      &lt;version&gt;3.1.0&lt;/version&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
                      &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
                      &lt;version&gt;0.8.6&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;excludes&gt;
                              &lt;exclude&gt;**/util/SystemClock.class&lt;/exclude&gt;
                          &lt;/excludes&gt;
                      &lt;/configuration&gt;
                      &lt;executions&gt;
                          &lt;execution&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;prepare-agent&lt;/goal&gt;
                              &lt;/goals&gt;
                          &lt;/execution&gt;
                          &lt;execution&gt;
                              &lt;id&gt;report&lt;/id&gt;
                              &lt;phase&gt;test&lt;/phase&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;report&lt;/goal&gt;
                              &lt;/goals&gt;
                          &lt;/execution&gt;
                      &lt;/executions&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                      &lt;version&gt;3.0.0-M5&lt;/version&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/build&gt;
          
          &lt;profiles&gt;
              &lt;profile&gt;
                  &lt;build&gt;
                      &lt;plugins&gt;
                          &lt;plugin&gt;
                              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                              &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt;
                              &lt;version&gt;3.0.1&lt;/version&gt;
                              &lt;executions&gt;
                                  &lt;execution&gt;
                                      &lt;id&gt;attach-sources&lt;/id&gt;
                                      &lt;goals&gt;
                                          &lt;goal&gt;jar&lt;/goal&gt;
                                      &lt;/goals&gt;
                                  &lt;/execution&gt;
                              &lt;/executions&gt;
                          &lt;/plugin&gt;
                          &lt;plugin&gt;
                              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                              &lt;artifactId&gt;maven-javadoc-plugin&lt;/artifactId&gt;
                              &lt;version&gt;3.0.1&lt;/version&gt;
                              &lt;executions&gt;
                                  &lt;execution&gt;
                                      &lt;id&gt;attach-javadocs&lt;/id&gt;
                                      &lt;goals&gt;
                                          &lt;goal&gt;jar&lt;/goal&gt;
                                      &lt;/goals&gt;
                                  &lt;/execution&gt;
                              &lt;/executions&gt;
                          &lt;/plugin&gt;
                      &lt;/plugins&gt;
                  &lt;/build&gt;
              &lt;/profile&gt;
          &lt;/profiles&gt;
          
          &lt;pluginRepositories&gt;
              &lt;pluginRepository&gt;
                  &lt;id&gt;central&lt;/id&gt;
                  &lt;name&gt;Central Repository&lt;/name&gt;
                  &lt;url&gt;https://repo.maven.apache.org/maven2&lt;/url&gt;
                  &lt;layout&gt;default&lt;/layout&gt;
                  &lt;snapshots&gt;
                      &lt;enabled&gt;false&lt;/enabled&gt;
                  &lt;/snapshots&gt;
                  &lt;releases&gt;
                      &lt;updatePolicy&gt;never&lt;/updatePolicy&gt;
                  &lt;/releases&gt;
              &lt;/pluginRepository&gt;
          &lt;/pluginRepositories&gt;
      
          &lt;repositories&gt;
              &lt;repository&gt;
                  &lt;id&gt;central&lt;/id&gt;
                  &lt;name&gt;Central Repository&lt;/name&gt;
                  &lt;url&gt;https://repo.maven.apache.org/maven2&lt;/url&gt;
                  &lt;layout&gt;default&lt;/layout&gt;
                  &lt;snapshots&gt;
                      &lt;enabled&gt;false&lt;/enabled&gt;
                  &lt;/snapshots&gt;
              &lt;/repository&gt;
          &lt;/repositories&gt;
          &lt;name&gt;Automation_Framework&lt;/name&gt;
      &lt;/project&gt;
  </code></pre>
  <p>You'll notice I have an exclusion by the actual dependency jar for the company I work for:</p>
  <pre><code>&lt;!-- Company Jar (API) --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;this.jar.file&lt;/groupId&gt;
          &lt;artifactId&gt;api-bundle&lt;/artifactId&gt;
          &lt;version&gt;1.0&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
          &lt;exclusions&gt;
            &lt;exclusion&gt;  &lt;!-- declare the exclusion here --&gt;
              &lt;groupId&gt;this.jar.file&lt;/groupId&gt;
              &lt;artifactId&gt;api-bundle&lt;/artifactId&gt;
            &lt;/exclusion&gt;
          &lt;/exclusions&gt; 
      &lt;/dependency&gt;
  </code></pre>
  <p>as well as by the JaCoCo plugin section</p>
  <pre><code>     &lt;plugin&gt;
          &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
          &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;0.8.6&lt;/version&gt;
          &lt;configuration&gt;
              &lt;excludes&gt;
                  &lt;exclude&gt;**/util/SystemClock.class&lt;/exclude&gt;
              &lt;/excludes&gt;
          &lt;/configuration&gt;
          &lt;executions&gt;
              &lt;execution&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;prepare-agent&lt;/goal&gt;
                  &lt;/goals&gt;
              &lt;/execution&gt;
              &lt;execution&gt;
                  &lt;id&gt;report&lt;/id&gt;
                  &lt;phase&gt;test&lt;/phase&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;report&lt;/goal&gt;
                  &lt;/goals&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;
      &lt;/plugin&gt;
  </code></pre>
  <p>neither works (at least that I can tell).</p>
  <p>I honestly don't understand the half of the &quot;technical talk&quot; that I read and I am sure with more reading throughout my time of investigating all of this, I will begin to understand it BUT I cannot wait until I magically figure it out, so I am hoping someone can assist.</p>
  <p>It's the first time I have setup a project like this, so admittedly there's plenty for me to still learn.</p>