Bug 175226 - [buildpath] Build path contains duplicate entry
Summary: [buildpath] Build path contains duplicate entry
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major with 1 vote (vote)
Target Milestone: 3.4.2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 183297 194006 251540 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-02-23 03:00 EST by Borut Bolčina CLA
Modified: 2009-02-03 12:23 EST (History)
7 users (show)

See Also:
jerome_lanneluc: review+


Attachments
A dialog with warning of duplicate classpath entry (75.57 KB, image/png)
2007-02-23 03:07 EST, Borut Bolčina CLA
no flags Details
Proposed fix and regression tests (8.82 KB, patch)
2008-10-10 12:47 EDT, Jerome Lanneluc CLA
no flags Details | Diff
Same fix and tests for R3_4_maintenance (8.66 KB, patch)
2008-10-24 09:12 EDT, Jerome Lanneluc CLA
no flags Details | Diff
Same fix with improved wordings and same tests for R3_4_maintenance (8.65 KB, patch)
2008-10-27 10:45 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Borut Bolčina CLA 2007-02-23 03:00:12 EST
Build ID: M20070212-1330

Steps To Reproduce:
My project is WTP and Maven enabled. I have upgraded Eclipse wia standard update procedure. Now my project is not showing source packages.

1.Open Project's Properties > Java Build Path
2.Tab Source contains no entries. By adding new Folder with my source java files a warning pops up saying I have a duplicate entry in my build path.



More information:
This is my .classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5"/>
	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
	<classpathentry kind="output" path="build/classes"/>
</classpath>

Obviously there is no source entry, so packages are not showing in my Package Explorer. But when trying to add source folder, it says I have duplicate entries!
Comment 1 Borut Bol&#269;ina CLA 2007-02-23 03:07:01 EST
Created attachment 59632 [details]
A dialog with warning of duplicate classpath entry
Comment 2 Jerome Lanneluc CLA 2007-04-24 09:09:57 EDT
Could it be that one of the classpath containers already define this source entry ? They should not but we don't check for this and this would result in this message.
Comment 3 Philipe Mulet CLA 2008-01-16 06:00:57 EST
I wonder if we shouldn't silently ignore such a scenario. This is no user mistake, and we could recover easily (only keep the first instance).
Comment 4 Cédric CLA 2008-01-18 06:48:00 EST
I have reproduced this issue on Eclipse 3.4M4.
It's very strange, it only appears on web project (which is WTP and Maven 2 enabled). Eclipse's validation prevent to build this project.

Furthermore, the same project works fine with Eclipse 3.3.

My pom.xml is the following :

<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/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.cedric.a01</groupId>
	<artifactId>test</artifactId>
	<packaging>war</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>Test Struts Maven Webapp</name>
	<url>http://maven.apache.org</url>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts-core</artifactId>
			<version>1.3.8</version>
		</dependency>

		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts-extras</artifactId>
			<version>1.3.8</version>
		</dependency>

		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts-taglib</artifactId>
			<version>1.3.8</version>
		</dependency>
	</dependencies>

	<build>
		<finalName>test</finalName>

		<sourceDirectory>src/main/java</sourceDirectory>
		<testSourceDirectory>src/test/java</testSourceDirectory>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
			</testResource>
		</testResources>

		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
					<version>2.0.2</version>
					<configuration>
						<source>1.5</source>
						<target>1.5</target>
					</configuration>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-eclipse-plugin</artifactId>
					<version>2.4</version>
					<configuration>
						<downloadSources>true</downloadSources>
						<wtpContextName>codex</wtpContextName>
						<wtpversion>1.5</wtpversion>
						<classpathContainers>
							<classpathContainer>
								org.eclipse.jdt.launching.JRE_CONTAINER
							</classpathContainer>
							<classpathContainer>
								org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache
								Tomcat v6.0.13
							</classpathContainer>
							<classpathContainer>
								org.eclipse.jst.j2ee.internal.module.container
							</classpathContainer>
							<classpathContainer>
								org.eclipse.jst.j2ee.internal.web.container
							</classpathContainer>
						</classpathContainers>
						<additionalProjectnatures>
							<projectnature>
								org.eclipse.wst.common.project.facet.core.nature
							</projectnature>
							<projectnature>
								org.eclipse.jdt.core.javanature
							</projectnature>
							<projectnature>
								org.eclipse.wst.common.modulecore.ModuleCoreNature
							</projectnature>
							<projectnature>
								org.eclipse.jem.workbench.JavaEMFNature
							</projectnature>
							<projectnature>
								org.eclipse.wst.jsdt.core.jsNature
							</projectnature>
						</additionalProjectnatures>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
</project>
Comment 5 Philipe Mulet CLA 2008-01-18 08:00:49 EST
I think you can force it to build still in presence of buildpath errors (as a workaround). Look under: Preferences>Java>Compiler>Building>Abort build when build path errors occur (disable the check box).

Comment 6 Jerome Lanneluc CLA 2008-02-26 09:53:29 EST
*** Bug 194006 has been marked as a duplicate of this bug. ***
Comment 7 Jerome Lanneluc CLA 2008-02-26 10:02:09 EST
*** Bug 183297 has been marked as a duplicate of this bug. ***
Comment 8 Philipe Mulet CLA 2008-04-10 07:34:12 EDT
Reducing severity since there is a workaround.
Comment 9 Jerome Lanneluc CLA 2008-10-10 12:47:32 EDT
Created attachment 114820 [details]
Proposed fix and regression tests

This fix consists in checking duplicate entries at the raw classpath level only. If entries are duplicate because of the resolution, only the first entry is kept (this is what we've done until now since we always lookup entries in the resolved classpath order).
Comment 10 Jerome Lanneluc CLA 2008-10-13 06:46:38 EDT
Fix and tests released for 3.5M3
Comment 11 Jerome Lanneluc CLA 2008-10-24 09:10:17 EDT
*** Bug 251540 has been marked as a duplicate of this bug. ***
Comment 12 Jerome Lanneluc CLA 2008-10-24 09:12:14 EDT
Created attachment 116045 [details]
Same fix and tests for R3_4_maintenance
Comment 13 Rob Gaunt CLA 2008-10-24 12:51:28 EDT
(In reply to comment #12)
> Created an attachment (id=116045) [details]
> Same fix and tests for R3_4_maintenance
> 

Thanks for the patch to 3.4 per 251540
Comment 14 Jerome Lanneluc CLA 2008-10-27 05:29:21 EDT
Philippe, ok to backport to 3.4.2? This limitation just annoys users and the fix is quite safe.
Comment 15 Philipe Mulet CLA 2008-10-27 09:02:28 EDT
I am a bit puzzled by the API refinement:
+	 * <p>
+	 * Since 3.5, if the resolution creates duplicate entries 
+	 * (i.e. {@link IClasspathEntry entries} which are {@link Object#equals(Object)}), 
+	 * only the first one is added to the resolved classpath.
+	 * </p>


would this be ok for 3.4 ?
Comment 16 Jerome Lanneluc CLA 2008-10-27 10:45:50 EDT
Created attachment 116185 [details]
Same fix with improved wordings and same tests for R3_4_maintenance
Comment 17 Olivier Thomann CLA 2008-10-27 15:23:00 EDT
Verified for 3.5M3 using I20081026-2000
Comment 18 Philipe Mulet CLA 2008-10-29 06:16:58 EDT
+1 for 3.4.2
Comment 19 Jerome Lanneluc CLA 2008-10-30 06:19:26 EDT
Fix and tests released for 3.4.2
Comment 20 Frederic Fusier CLA 2009-02-03 12:23:07 EST
Verified for 3.4.2 by running ClasspathTests v_894_R34x in a 3.4.1 wksp