Duplicate Class Error Maven
Contents |
here for a quick overview of the duplicate class error in ant build site Help Center Detailed answers to any questions you might have
Duplicate Class Error Netbeans
Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business java duplicate class error Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just maven find duplicate classes like you, helping each other. Join them; it only takes a minute: Sign up Eclipse Maven Plugin: Duplicate Class Error up vote 0 down vote favorite I'm trying to deploy my project using Maven in Eclipse, but I am getting a lot of duplicate class errors. Here is my pom.xml:
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Maven Ignore Duplicate Classes
this site About Us Learn more about Stack Overflow the company Business Learn maven duplicate class warning more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question
Maven Remove Duplicate Dependencies
x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up http://stackoverflow.com/questions/19544572/eclipse-maven-plugin-duplicate-class-error Why would compiler fail on duplicate class if they belong to different packages? up vote 0 down vote favorite I got this inherited project using Maven/m2e as the build automation tool. All nice & cool except that this project, checked out of SVN as is, is broken... meaning it fails to build, with several duplicate class errors: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) http://stackoverflow.com/questions/13745003/why-would-compiler-fail-on-duplicate-class-if-they-belong-to-different-packages on project myproj: Compilation failure: Compilation failure: [ERROR] \Users\Daniel\workspace\myproj\target\generated-sources\cxf\org\package1\services\ClassA.java:[36,7] duplicate class: org.package1.services.ClassA Now, it's true that ClassA exists in the build environment 3 times: c:/Users/Daniel/workspace/myproj/src/main/java/org/package1/services/ClassA.java c:/Users/Daniel/workspace/myproj/src/main/java/org/package1/www/services/ClassA.java c:/Users/Daniel/workspace/myproj/target/generated-sources/cxf/org/package1/services/ClassA.java But they belong to different packages: package org.package1.services; package org.package1.www.services; So, why would the compiler complain about a duplicate class? (Or is it Maven that's complaining?) I am not familiar with the design considerations of the original author, so any idea how to resolve these duplicates would be much appreciated. java maven m2e share|improve this question asked Dec 6 '12 at 13:51 Withheld 1,80442854 add a comment| 3 Answers 3 active oldest votes up vote 4 down vote accepted You've got three classes, in two packages. Therefore two of the classes are in the same package. These two files: .../myproj/src/main/java/org/package1/services/ClassA.java .../myproj/target/generated-sources/cxf/org/package1/services/ClassA.java ... are both contributing org.package1.services.ClassA (which is the fully-qualified class name the compiler is complaining about, note). It's not clear which one you should be using, based on the information you've given. share|improve this answer answered Dec 6 '12 at 13:55 Jon Skeet 899k48665207455 Thanks. It's not clear to me either which one I should be using.
BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Compilation failure /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/clover/src-instrumented/com/atlassian/jira/soap/client/PingStringInput.java:[35,7] duplicate class: com.atlassian.jira.soap.client.PingStringInput /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/jaxws/wsimport/java/com/atlassian/jira/soap/client/PingServicePortType.java:[23,7] duplicate class: https://issues.apache.org/jira/browse/MCOMPILER-235 com.atlassian.jira.soap.client.PingServicePortType /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/clover/src-instrumented/com/atlassian/jira/soap/client/ObjectFactory.java:[22,7] duplicate class: com.atlassian.jira.soap.client.ObjectFactory /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/clover/src-instrumented/com/atlassian/jira/soap/client/PingService.java:[21,7] duplicate class: com.atlassian.jira.soap.client.PingService /Users/amyers/Applications/clover/mavenbook-examples-1-SNAPSHOT/ch05-simple-web/simple-webapp/target/jaxws/wsimport/java/com/atlassian/jira/soap/client/package-info.java:[1,0] package com.atlassian.jira.soap.client has already been duplicate class annotated Cause The jaxws-maven-plugin adds the output directory for the generated sources to the compile source roots. Clover changes the ${project.build.sourceDirectory} to target/clover/src-instrumented when it performs the instrumentation, thus maven ends duplicate class error up having both the original generated code and the instrumented code on the compile path. Resolution Configure the jaxws-maven-plugin to use ${project.build.sourceDirectory} as the
due to MCOMPILER-157 when compiler is called twice or moreAgile Board ExportXMLWordPrintableJSON Details Type: Bug Status: Closed Priority: Major Resolution: Fixed Affects Version/s: 3.2 Fix Version/s: 3.5.1 Labels: None Environment: Maven 3.2.3 Description I tried to upgrade our projects to use the compiler 3.2 and instead of 3.1 Classical builds are ok but site builds are KO because for various reasons (reports) the lifecycle is forked and thus the compiler is called twice (or more) and fails because it finds duplicated classes Example : [INFO] ------------------------------------------------------------------------ [INFO] Building eXo Commons - Common Services 4.1.x-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-java-version) @ commons-component-common --- [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-maven-version) @ commons-component-common --- [INFO] [INFO] --- buildnumber-maven-plugin:1.3:create (default) @ commons-component-common --- [INFO] [INFO] --- jacoco-maven-plugin:0.7.2.201409121644:prepare-agent (prepare-ut-agent) @ commons-component-common --- [INFO] argLine set to -javaagent:/srv/ciagent/workspace/commons-master-site/.repository/org/jacoco/org.jacoco.agent/0.7.2.201409121644/org.jacoco.agent-0.7.2.201409121644-runtime.jar=destfile=/srv/ciagent/workspace/commons-master-site/sources/commons-component-common/target/jacoco.exec,append=true [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ commons-component-common --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] Copying 5 resources [INFO] [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ commons-component-common --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 97 source files to /srv/ciagent/workspace/commons-master-site/sources/commons-component-common/target/classes [WARNING] Supported source version 'RELEASE_5' from annotation processor 'org.chromattic.apt.ChromatticProcessor' less t