Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reindexing local Maven Repo in fresh Eclipse install fails with java.nio.channels.OverlappingFileLockException

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

Eclipse Error Screenshot with settings shown

I already tried:

  • moving the Maven repo to a fresh and/or empty location
  • starting with a fresh eclipse install and fresh workspace folder
  • restarting the system and installing a fresh eclipse, eclipse workspace and maven repo

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)
like image 583
FrozenSUSHI Avatar asked Mar 02 '21 15:03

FrozenSUSHI


People also ask

How to change Maven repository location in Eclipse?

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.

Why is my local Repo not available in Maven?

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.

How to resolve the overlappingfilelockexception when reindexing in Eclipse?

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.

Where are Maven dependency jars?

When a Maven build is executed, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named .m2.


1 Answers

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

like image 133
Subhajit Avatar answered Oct 18 '22 21:10

Subhajit