Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange linked-resource error when importing Maven Project #1912

Open
srl295 opened this issue Jan 7, 2025 · 1 comment
Open

Strange linked-resource error when importing Maven Project #1912

srl295 opened this issue Jan 7, 2025 · 1 comment

Comments

@srl295
Copy link

srl295 commented Jan 7, 2025

Summary Error

When importing a Maven project tree, an obscure message. The user wasn't trying to create a linked resource, but just to open a project.

Cannot create a link to path/cldr2' because it overlaps the location of the project that contains the linked resource.

The message seems to be coming from tools/cldr-code/pom.xml - project name cldr-code which is 2 levels deep from the cldr2 directory mentioned, which is the root project.

Side Request

I don't know if this next message is addressed at the correct level of a very complex stack, but: Please consider improving the message reporting structure here with much more context. It's not an actionable error message.

Background

Hello. Another user at least has seen this as well, and it's been reproduced across both the Eclipse IDE and VSCode. I'm including VSCode details because it has stack traces.

Tracking this downstream at https://unicode-org.atlassian.net/browse/CLDR-18205

To reproduce:

  1. check out https://github.com/unicode-org/cldr.git
  2. Eclipse: Import the root as an existing Maven project. VSCode: just open the directory and check the VSCode Java logs.

Details:

  message: '[Error - 9:14:48 AM] Jan 7, 2025, 9:14:46 AM Failed to import projects\n' +
    "Cannot create a link to '/Users/srl295/src/cldr2' because it overlaps the location of the project that contains the linked resource.\n" +
    "org.eclipse.core.internal.resources.ResourceException: Cannot create a link to '/Users/srl295/src/cldr2' because it overlaps the location of the project that contains the linked resource.\n" +
    '\tat org.eclipse.core.internal.resources.Resource.assertLinkRequirements(Resource.java:204)\n' +
    '\tat org.eclipse.core.internal.resources.Resource.createLink(Resource.java:671)\n' +
    '\tat org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getFolder(AbstractJavaProjectConfigurator.java:905)\n' +
    '\tat org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addResourceDirs(AbstractJavaProjectConfigurator.java:541)\n' +
    '\tat org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addProjectSourceFolders(AbstractJavaProjectConfigurator.java:395)\n' +
    '\tat org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.configure(AbstractJavaProjectConfigurator.java:165)\n' +
    '\tat org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:123)\n' +
    '\tat org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$6(ProjectConfigurationManager.java:503)\n' +
    '\tat org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:458)\n' +
    '\tat org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:339)\n' +
    '\tat org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:497)\n' +
    '\tat org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.configureNewMavenProjects(ProjectConfigurationManager.java:278)\n' +
    '\tat org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$1(ProjectConfigurationManager.java:165)\n' +
    '\tat org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:458)\n' +
    '\tat org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:339)\n' +
    '\tat org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:278)\n' +
    '\tat org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:138)\n' +
    '\tat org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:129)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.managers.MavenProjectImporter.importToWorkspace(MavenProjectImporter.java:242)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:164)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:126)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:277)\n' +
    '\tat org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)\n' +
    '\tat org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)\n',
  level: 'info',
  timestamp: '2025-01-07 09:14:48.284'
}
{
  message: '[Error - 9:14:48 AM] Jan 7, 2025, 9:14:46 AM Initialization failed \n' +
    'Failed to import projects\n' +
    'org.eclipse.core.runtime.CoreException: Failed to import projects\n' +
    '\tat org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:177)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:126)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:277)\n' +
    '\tat org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)\n' +
    '\tat org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)\n' +
    "Contains: Cannot create a link to '/Users/srl295/src/cldr2' because it overlaps the location of the project that contains the linked resource.\n",
  level: 'info',
  timestamp: '2025-01-07 09:14:48.348'
}
{
  message: '[Error - 9:14:50 AM] Jan 7, 2025, 9:14:50 AM Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ls.core".\n' +
    'cldr-code does not exist\n' +
    'Java Model Exception: Error in Java Model (code 969): cldr-code does not exist\n' +
    '\tat org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:546)\n' +
    '\tat org.eclipse.jdt.internal.core.JavaModelManager.getPerProjectInfoCheckExistence(JavaModelManager.java:2535)\n' +
    '\tat org.eclipse.jdt.internal.core.JavaProject.getPerProjectInfo(JavaProject.java:2329)\n' +
    '\tat org.eclipse.jdt.internal.core.JavaProject.getRawClasspath(JavaProject.java:2372)\n' +
    '\tat org.eclipse.m2e.jdt.internal.launch.MavenRuntimeClasspathProvider.addProjectEntries(MavenRuntimeClasspathProvider.java:324)\n' +
    '\tat org.eclipse.m2e.jdt.internal.launch.MavenRuntimeClasspathProvider.addMavenClasspathEntries(MavenRuntimeClasspathProvider.java:220)\n' +
    '\tat org.eclipse.m2e.jdt.internal.launch.MavenRuntimeClasspathProvider.resolveClasspath0(MavenRuntimeClasspathProvider.java:187)\n' +
    '\tat org.eclipse.m2e.jdt.internal.launch.MavenRuntimeClasspathProvider.lambda$2(MavenRuntimeClasspathProvider.java:170)\n' +
    '\tat org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:458)\n' +
    '\tat org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:339)\n' +
    '\tat org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:278)\n' +
    '\tat org.eclipse.m2e.jdt.internal.launch.MavenRuntimeClasspathProvider.resolveClasspath(MavenRuntimeClasspathProvider.java:170)\n' +
    '\tat org.eclipse.jdt.internal.launching.RuntimeClasspathProvider.resolveClasspath(RuntimeClasspathProvider.java:68)\n' +
    '\tat org.eclipse.jdt.launching.JavaRuntime.resolveRuntimeClasspath(JavaRuntime.java:1676)\n' +
    '\tat org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate.getClasspathAndModulepath(AbstractJavaLaunchConfigurationDelegate.java:464)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.lambda$8(ProjectCommand.java:435)\n' +
    '\tat org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2457)\n' +
    '\tat org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2482)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.getClasspathsFromJavaProject(ProjectCommand.java:434)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.commands.ProjectCommand.getClasspaths(ProjectCommand.java:414)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.JDTDelegateCommandHandler.executeCommand(JDTDelegateCommandHandler.java:101)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler$1.run(WorkspaceExecuteCommandHandler.java:230)\n' +
    '\tat org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.handlers.WorkspaceExecuteCommandHandler.executeCommand(WorkspaceExecuteCommandHandler.java:220)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$4(JDTLanguageServer.java:610)\n' +
    '\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)\n' +
    '\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)\n' +
    '\tat java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)\n' +
    '\tat java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)\n' +
    '\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)\n' +
    '\tat java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)\n' +
    '\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)\n' +
    '\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)\n',
  level: 'info',
  timestamp: '2025-01-07 09:14:50.291'
}
@srl295
Copy link
Author

srl295 commented Jan 7, 2025

OK, by much analysis I found out what was triggering this error. Two levels deep into poms we have a <resource> reference that pulls a file from the top level directory (cldr2 in the above error message).

This is valid in Maven, so seems to be an m2e bug.

Seems like m2e, if it wants to make a linked resource, should just reference the top level file — LICENSE is already a part of the top level project.

diff --git a/tools/cldr-code/pom.xml b/tools/cldr-code/pom.xml
index 9dc23550d8..4a479cf3b5 100644
--- a/tools/cldr-code/pom.xml
+++ b/tools/cldr-code/pom.xml
@@ -69,23 +69,6 @@
 			<resource>
 				<directory>src/main/resources</directory>
 			</resource>
-			<resource>
-		       <directory>${project.basedir}/../..</directory>
-			   <!-- This is put here so that it can be read by CldrUtility, even outside of a jar -->
-		       <targetPath>${project.build.directory}/classes/org/unicode/cldr/util/data</targetPath>
-				<includes>
-					<include>LICENSE</include>
-				</includes>
-			</resource>
-			<resource>
-		       <directory>${project.basedir}/../..</directory>
-			   <!-- This is put here so that it shows up in the final .jar in an expected spot -->
-			   <!-- Note: icu4j keeps its license file at the root, /LICENSE. We won't conflict. -->
-		       <targetPath>META-INF</targetPath>
-				<includes>
-					<include>LICENSE</include>
-				</includes>
-			</resource>
 		</resources>
 		<plugins>
 			<plugin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant