This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 197983 - Duplicate Class error
Summary: Duplicate Class error
Status: VERIFIED INCOMPLETE
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal with 5 votes (vote)
Assignee: Jan Lahoda
URL:
Keywords:
: 198466 215437 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-04-22 05:12 UTC by debopamg
Modified: 2016-06-08 08:01 UTC (History)
9 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screencap showing duplicate file warning (68.57 KB, image/png)
2011-07-19 18:26 UTC, slass100
Details
~/.netbeans/var/log/message.log (40.59 KB, text/plain)
2011-07-19 18:28 UTC, slass100
Details

Note You need to log in before you can comment on or make changes to this bug.
Description debopamg 2011-04-22 05:12:46 UTC
Product Version = NetBeans IDE 7.0 RC1 (Build 201103280000)
Operating System = Linux version 2.6.35-28-generic running on i386
Java; VM; Vendor = 1.6.0_24
Runtime = Java HotSpot(TM) Client VM 19.1-b02


There was a git merge conflict, and after resolving it (outside the IDE, using Meld), I find that the IDE is reporting the conflicted class as Duplicate class. 

I am using the GIT plugin.
Comment 1 Ondrej Vrabec 2011-05-17 09:39:11 UTC
What does it mean "Duplicate class"? Can you make a screenshot?
Comment 2 Ondrej Vrabec 2011-05-19 08:19:36 UTC
Please explain further
Comment 3 debopamg 2011-05-19 09:29:47 UTC
The problem occurs under the following circumstances:
1. the netbeans git plugin is installed
2. a merge/rebase is performed with the remote git repo
3. there is a conflict in one of the files
4. the conflict is resolved using an external tool (like Meld)
4. after the conflict is resolved, and the change commited, netbeans shows Duplicate class error for the class for which there was a conflict.

Hope that helps. I am unable to reproduce this error right now since there are no conflicts.
Comment 4 Ondrej Vrabec 2011-05-19 09:45:22 UTC
> Hope that helps. I am unable to reproduce this error right now since there are
> no conflicts.
I cannot reproduce either. Merged, resolved conflicts in commandline and then switched back to IDE, but got no such error.
When it occurs again, attach the message.log (http://wiki.netbeans.org/FaqLogMessagesFile) and make a screenshot, honestly i have no idea what the "Duplicate class error" could be.
Comment 5 slass100 2011-07-19 18:26:55 UTC
Created attachment 109519 [details]
screencap showing duplicate file warning

screencap of issue.  message log to follow.
Comment 6 slass100 2011-07-19 18:28:16 UTC
Created attachment 109520 [details]
~/.netbeans/var/log/message.log

message log
Comment 7 slass100 2011-07-19 18:29:39 UTC
re-opened because I also have this issue.  i am unable to "fix"/workaround.
Comment 8 Ondrej Vrabec 2011-07-19 18:47:24 UTC
(In reply to comment #7)
Did this happen also after a merge?
> re-opened because I also have this issue.  i am unable to "fix"/workaround.
Well, isn't this because the merge failed and CUPI class is now coded twice in the file?
Comment 9 slass100 2011-07-19 20:08:46 UTC
(In reply to comment #8)
> (In reply to comment #7)
> Did this happen also after a merge?

Most likely, but I'm not sure the exactly steps I took to get here.

> > re-opened because I also have this issue.  i am unable to "fix"/workaround.
> Well, isn't this because the merge failed and CUPI class is now coded twice in
> the file?

No, there is only a single class defined in the .java source file.  

Even though the IDE shows errors due to the "duplicate class", I can still edit the file, F9 (compile) file, Shift+F6 (run), etc.
Comment 10 Ondrej Vrabec 2011-07-20 07:04:48 UTC
Annotations are probably not recomputed after the file gets to the correct state after a merge, reassigning to java. Could you look at it?
Comment 11 guyer 2011-12-18 07:58:09 UTC
Not sure if still relevant, but the problem is netbeans for sure.
Happens to me all the time after merge conflicts.
Workaround to solve this:
* close netbeans
* Delete netbeans cache directory. For linux it's: ~/.netbeans/<version>/var/cache/*. Where <version> is the netbeans version, like 7.0
* restart netbeans
Comment 12 Merkator 2012-02-09 09:48:50 UTC
Same bug, same circumstances : git > merge with conflict > edited with an other tools (outside Netbeans) > Duplicate class.

Like in screensshoot, all class in the same package are considered like duplicate class. Other packages are not affected.

Workaround purpose by guyer@netbeans.org work correctly. Thank you

Good bye
Comment 13 tasmaniski 2012-06-19 09:47:30 UTC
I had the same problem on Ubuntu and 
I deleted cache dir like guyer@netbeans.org said, 
and now everything works fine. 

Thanks guyer !!!
Comment 14 gooddreams 2012-08-27 03:56:13 UTC
I also met this problem several times. The latest one is now with NB7.2 on Mac.
Due to some unknown problem, SVN update report error on some file that can not updated due to MD5 not match. So I have to delete the dir which contains the file and re-checkout the whole dir. This resolved the SVN issue, but NetBeans will report the error "Duplicate class error" on the source file editor. This error will cause other issues, such as report warning when use findbugs, can not refactor the class etc.

I thought maybe a simple solution is just add an action to context menu just delete cached index items. Currently my work around is manually delete the whole index dir in cache.
Comment 15 Qnan 2012-08-31 09:04:34 UTC
Got the same one after trying to rebase. Had to git rebase --abort and git reset --hard HEAD^, after that found the Duplicate class error when opening NetBeans. The same version of the code on the other machine compiles perfectly and I can ant clean && ant build from command line on this machine just fine.

Checked the netbeans cache directory, using "grep -R 'Dual' ~/.netbeans/7.1.2/var/cache/", where "Dual" is the name of the supposedly duplicate class. I think this part of it is relevant:

.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BACKUP/4846.rs:se.lth.cs.srl.Dual
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BACKUP/4846.rs:se.lth.cs.srl.Dual$1
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BACKUP/4846.rs:se.lth.cs.srl.Dual$ROLE_CORR_MATR_MODE
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BASE/4846.rs:se.lth.cs.srl.Dual
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BASE/4846.rs:se.lth.cs.srl.Dual$1
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BASE/4846.rs:se.lth.cs.srl.Dual$ROLE_CORR_MATR_MODE
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/LOCAL/4846.rs:se.lth.cs.srl.Dual
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/LOCAL/4846.rs:se.lth.cs.srl.Dual$1
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/LOCAL/4846.rs:se.lth.cs.srl.Dual$ROLE_CORR_MATR_MODE
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/REMOTE/4846.rs:se.lth.cs.srl.Dual
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/REMOTE/4846.rs:se.lth.cs.srl.Dual$1
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/REMOTE/4846.rs:se.lth.cs.srl.Dual$ROLE_CORR_MATR_MODE


P.S. that's on Mac OS X 10.5, Netbeans 7.1.2
Comment 16 Qnan 2012-08-31 09:05:09 UTC
Got the same one after trying to rebase. Had to git rebase --abort and git reset --hard HEAD^, after that found the Duplicate class error when opening NetBeans. The same version of the code on the other machine compiles perfectly and I can ant clean && ant build from command line on this machine just fine.

Checked the netbeans cache directory, using "grep -R 'Dual' ~/.netbeans/7.1.2/var/cache/", where "Dual" is the name of the supposedly duplicate class. I think this part of it is relevant:

.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BACKUP/4846.rs:se.lth.cs.srl.Dual
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BACKUP/4846.rs:se.lth.cs.srl.Dual$1
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BACKUP/4846.rs:se.lth.cs.srl.Dual$ROLE_CORR_MATR_MODE
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BASE/4846.rs:se.lth.cs.srl.Dual
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BASE/4846.rs:se.lth.cs.srl.Dual$1
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/BASE/4846.rs:se.lth.cs.srl.Dual$ROLE_CORR_MATR_MODE
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/LOCAL/4846.rs:se.lth.cs.srl.Dual
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/LOCAL/4846.rs:se.lth.cs.srl.Dual$1
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/LOCAL/4846.rs:se.lth.cs.srl.Dual$ROLE_CORR_MATR_MODE
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/REMOTE/4846.rs:se.lth.cs.srl.Dual
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/REMOTE/4846.rs:se.lth.cs.srl.Dual$1
.../var/cache/index/s83/java/14/classes/se/lth/cs/srl/Dual/java/REMOTE/4846.rs:se.lth.cs.srl.Dual$ROLE_CORR_MATR_MODE


P.S. that's on Mac OS X 10.5, Netbeans 7.1.2
Comment 17 vallej 2012-09-13 17:28:00 UTC
Hey, Netbeans guys! Everybody who use GIT have to delete that cache folder or use another IDE. Why it is still not fixed?
Comment 18 Jan Lahoda 2012-09-13 18:39:48 UTC
(In reply to comment #17)
> Hey, Netbeans guys! Everybody who use GIT have to delete that cache folder or
> use another IDE. Why it is still not fixed?

Hi,

If you can provide steps to reproduce (i.e. clone this repository, run this command, then this command and then you will see the bug), that would surely going to help a lot and would allow us to provide a fix much faster.

Thanks.
Comment 19 vallej 2012-09-13 19:00:38 UTC
Sure. You just need to get any conflict in git while netbeans have opened. 

... few minutes later

That's really strange. I get the issue _every_ time I get _any_ conflict in my java-freeform project (actually, it's android project), but I've tried to reproduce the issue by creating a conflict in helloworld project and fresh git repository and I am unable to reproduce it :-/

I keep you informed.
Comment 20 r78v10a07 2012-10-03 16:45:02 UTC
Hi,
I am using Netbeans 7.2 on OpenSuse 12.2 with subversion to googlecode. I have the same error with a duplicate class that was previously with a svn conflic.

I delete the VAR folders and restart the netbeans.

~/.netbeans/7.2/var/
/usr/local/netbeans-7.2/nb/var

This did not solved the problem. The project compiles well in the Netbeans and directly in the folder with the Maven command
Comment 21 vallej 2012-10-08 21:49:56 UTC
UPD: Seems it happens only while resolving conflicts of REBASE'ing. Deleting contents of var/cache/ always resolves the issue.
Comment 22 r78v10a07 2012-10-09 06:42:20 UTC
(In reply to comment #21)
> UPD: Seems it happens only while resolving conflicts of REBASE'ing. Deleting
> contents of var/cache/ always resolves the issue.

Hi, I delete the var folder mentioned before with not success. I solve the problem closing the netbeans and changing the Class name (also, file name) and reopened the project. I did the rename process out of the IDE because it don't let me change the name where there are conflicts on the class.
Comment 23 sdaclin 2012-10-15 11:01:23 UTC
I had the same problem with NB 7.2 on Win 7.
The cache directory solution worked for me, cache on windows platform is lacated there : 
    C:\Users\$userName\AppData\Local\NetBeans\Cache\7.2
Comment 24 Jan Lahoda 2012-11-07 14:52:19 UTC
*** Bug 198466 has been marked as a duplicate of this bug. ***
Comment 25 hennr 2012-11-07 16:07:37 UTC
Workaround under Debian with NB 7.2: delete ~/.cache/netbeans/VERSION/
Comment 26 hennr 2012-11-08 08:22:57 UTC
I created a small java project with instructions on how to reproduce the bug:

https://github.com/hennr/NetBeansDupplicateClassMergeBug

The README provides a step-by-step guide to reproduce the bug.
If you got further questions please let me know.
Comment 27 Jan Lahoda 2012-11-08 20:09:41 UTC
(In reply to comment #26)
> I created a small java project with instructions on how to reproduce the bug:
> 
> https://github.com/hennr/NetBeansDupplicateClassMergeBug
> 
> The README provides a step-by-step guide to reproduce the bug.
> If you got further questions please let me know.


Thank you very much for the test case. This should solve the problem:
http://hg.netbeans.org/jet-main/rev/724bc2a2a94d

A note should be added to this bug when a daily build will be available with the bugfix - would be awesome if someone could try to verify the problem is really solved. Thank you.
Comment 28 Quality Engineering 2012-11-09 02:53:17 UTC
Integrated into 'main-golden', will be available in build *201211090001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/724bc2a2a94d
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #197983: while conflicts are resolved inside a git repository, several files that contain dots and have the .java extension are generated. Correct .rs files must be generated for them, on correct places, and these must not be deleted while deleting a different Java file
Comment 29 hennr 2012-11-12 07:50:37 UTC
I can't confirm the bug any more either, thanks!

I'm very impressed by your processes here by the way. Love the update we got from the build management tool.
Comment 30 Jan Lahoda 2013-01-04 08:50:00 UTC
*** Bug 215437 has been marked as a duplicate of this bug. ***
Comment 31 Jackie_Rosen 2014-02-16 11:23:35 UTC
SPAM - Removed by Administrator
Comment 32 Jackie_Rosen 2014-02-16 11:23:58 UTC
SPAM - Removed by Administrator
Comment 33 FienZ 2014-02-25 13:39:03 UTC
I still have this issue in 7.4. Sorry I was not able to find another place to comment.
Comment 34 marcopar 2014-03-04 14:52:33 UTC
i got it too today

solved by deleting the cache
Comment 35 marcopar 2014-03-04 14:55:06 UTC
version 7.4, linux

sorry for the double comment

anyway this reminds me the good old days of the first netbeans 5 releases where deleting the cache was part of the development process :)
Comment 36 pwvirgo 2014-04-16 21:20:02 UTC
I am glad I found this post,thanks to everyone!

I am having the same problem using Netbeans 7.3 with Mercurial (after homemade  "rebase" by creating a new repository) - almost 3 years after this trail began.

Especially valuable was the post by sdaclin@netbeans.org pointing me to the correct windows directory and the correct NB cache:

C:\Users\$userName\AppData\Local\NetBeans\Cache\7.3
Comment 37 vincewebb 2014-05-13 16:14:19 UTC
I had an unexpected "duplicate class" error using NetBeans 8. I have a class named "Whatever", NetBeans thought I had multiple classes called "Whatever".

Thanks to the previous post by pwvirgo@netbeans.org 2014-04-16 21:20:02 UTC 

I renamed:
C:\Users\$userName\AppData\Local\NetBeans\Cache\8.0
to become
C:\Users\$userName\AppData\Local\NetBeans\Cache\8.0hidden

and that solved the problem, for now.

Unlike earlier posts, I had not been doing any messing about the repository. We use SVN.
Comment 38 garisty 2015-04-07 01:31:52 UTC
Just had this happen to me as well on version 8.0.2.

Workaround was same as vincewebb.

In my case, I am using git and problem occurred after refactoring (renaming) a class/file several times.
Comment 39 matvei 2015-04-28 16:57:39 UTC
Just experienced a similar problem, in NetBeans 8.0.2 (Java 7u45 x64, on Windows 7 Enterprise SP1 x64).

I had several Maven NetBeans Module project open. One of them was highlighted in the "Projects" pane as "containing errors", which came from "Bundle.java" under "Generated Sources (annotations)" folder. Opening that file in the editor showed no errors.

Doing "Clean & Build" worked every time, without errors. Attempting incremental "Build" resulted in "duplicate class" error on that generated Bundle class.

This error started happening immediately after I updated nbm-maven-plugin from 3.13 to 3.14 and cleaned the local Maven repo. Deleting NetBeans' cache directory solved the problem completely -- no more error messages or failed incremental builds.
Comment 40 matvei 2015-04-28 18:28:59 UTC
In addition to my previous comment:

We found a semi-consistent way to reproduce this problem, and the "duplicate class" error only appears to happen with maven-compiler-plugin versions 3.2 and 3.3. I cannot reproduce this problem with versions 2.5.1, 3.0, or 3.1. So it could be something specific to those plugins.
Comment 41 steveoh444 2016-06-08 08:01:34 UTC
Thanks @vincewebb 

--
I renamed:
C:\Users\$userName\AppData\Local\NetBeans\Cache\8.1
to become
C:\Users\$userName\AppData\Local\NetBeans\Cache\8.1_
and that solved the problem, for now.
--