Having a completely fresh install of Eclipse for EE Version: 2020-12 (4.18.0) on Win10 whenever I try to reindex it via the preferences dialog I get the following error:
Reindexing error
java.nio.channels.OverlappingFileLockException
I already tried:
Any ideas on what to check or where to look besides doing a full reinstall of the OS would be greatly appreciated.
Here is the full Stack trace for the error from the m2e log (as requested by @nitind ):
2021-03-02 16:02:18,461 [Worker-10: Indexing Local Repository...] ERROR o.e.m.c.i.i.nexus.NexusIndexManager - Unable to re-index workspace://
java.nio.channels.OverlappingFileLockException: null
at java.base/sun.nio.ch.FileLockTable.checkList(FileLockTable.java:229)
at java.base/sun.nio.ch.FileLockTable.add(FileLockTable.java:123)
at java.base/sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1297)
at java.base/java.nio.channels.FileChannel.tryLock(FileChannel.java:1178)
at org.apache.maven.index.context.DefaultIndexingContext.unlockForcibly(DefaultIndexingContext.java:927)
at org.apache.maven.index.context.DefaultIndexingContext.prepareIndex(DefaultIndexingContext.java:244)
at org.apache.maven.index.context.DefaultIndexingContext.purge(DefaultIndexingContext.java:612)
at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager.purgeCurrentIndex(NexusIndexManager.java:529)
at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager.reindexWorkspace(NexusIndexManager.java:561)
at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager.updateIndex(NexusIndexManager.java:1072)
at org.eclipse.m2e.core.internal.index.nexus.NexusIndex.updateIndex(NexusIndex.java:147)
at org.eclipse.m2e.core.ui.internal.preferences.MavenSettingsPreferencePage$2.runInWorkspace(MavenSettingsPreferencePage.java:263)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:42)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
m2_repo class variable must be added to eclipse’s class path variable on build path before using maven’s dependencies. 1. Manually change maven repository location in Eclipse 1.1. Navigate to Windows > Preferences 1.2. Navigate to Java > Build path > Classpath Variables 1.3.
Custom Local Repository in settings.xml If the repo is not present in this default location, it's likely because of some pre-existing configuration. That config file is located in the Maven installation directory – in a folder called conf – and is named settings.xml.
The problem was finally resolved by removing the system variable for M2_HOME that was pointing at an additional Maven installation on the system. Eclipse seems to invoke this 2nd one during the reindexing operation thus leading to the OverlappingFileLockException.
When a Maven build is executed, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named .m2.
I faced the same issue and could not find any solution on internet. By luck, I found a way to just once open the same workspace in STS4 click on Window->Preferences->Maven->User Settings. I found the Local Repository automatically resolved the local repository and downloaded the artifacts in the given location.
Now open again the same workspace in Eclipse and it can readily resolve the local repository used in STS4.
Also please note that I used a system variable to point the local repository location which was used in the User Settings file. So I found the solution to this while trying to resolve the issue of "Maven does not replace a variable in 'settings.xml' when it is invoked" which is asked here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With