为什么 Eclipse 在更新我的 Maven 项目时遇到 NPE?
Why is Eclipse hitting an NPE updating my Maven project?
我正在尝试将 Maven 项目拆分为子模块。它在命令行上构建良好,但是当导入到 eclipse 中时,一段时间后出现以下错误,然后我不得不重新导入项目。
项目结构为
- 我的应用
- 我的旧版应用程序
- 我的应用程序共享
在更新 maven 项目时确定路径时,eclipse 似乎遇到了 NPE。我该从哪里解决这个问题?
2020-10-20 15:23:12,368 [Worker-13: Updating maven profiles] WARN o.e.m.c.p.c.AbstractLifecycleMapping - Could not update project my-legacy-app configuration
java.lang.NullPointerException: null
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getProjectRelativePath(AbstractJavaProjectConfigurator.java:788) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getOtherResourceFolders(AbstractJavaProjectConfigurator.java:535) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.overlapsWithOtherResourceFolder(AbstractJavaProjectConfigurator.java:520) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addResourceDirs(AbstractJavaProjectConfigurator.java:475) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addProjectSourceFolders(AbstractJavaProjectConfigurator.java:341) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.configure(AbstractJavaProjectConfigurator.java:156) ~[na:na]
at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:122) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda(ProjectConfigurationManager.java:511) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:153) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:505) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:443) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda(ProjectConfigurationManager.java:358) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:153) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:101) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1370) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:357) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:343) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:325) ~[na:na]
at org.eclipse.m2e.profiles.core.internal.management.ProfileManager.updateActiveProfiles(ProfileManager.java:86) ~[na:na]
at org.eclipse.m2e.profiles.ui.internal.actions.ProfileSelectionHandler$UpdateProfilesJob.runInWorkspace(ProfileSelectionHandler.java:320) ~[na:na]
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:42) ~[na:na]
我最终抓取源代码到 m2e 并调试我的 Eclipse 实例,在 AbstractJavaProjectConfigurator.getProjectRelativePath()
上设置断点以直接检查 NPE 的源代码。
原因最终是 <resource>...</resource>
元素中缺少 <directory>...</directory>
元素。我没有早点找到它,因为 m2e/Eclipse 没有发现错误的任何上下文。
我正在尝试将 Maven 项目拆分为子模块。它在命令行上构建良好,但是当导入到 eclipse 中时,一段时间后出现以下错误,然后我不得不重新导入项目。
项目结构为
- 我的应用
- 我的旧版应用程序
- 我的应用程序共享
在更新 maven 项目时确定路径时,eclipse 似乎遇到了 NPE。我该从哪里解决这个问题?
2020-10-20 15:23:12,368 [Worker-13: Updating maven profiles] WARN o.e.m.c.p.c.AbstractLifecycleMapping - Could not update project my-legacy-app configuration
java.lang.NullPointerException: null
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getProjectRelativePath(AbstractJavaProjectConfigurator.java:788) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getOtherResourceFolders(AbstractJavaProjectConfigurator.java:535) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.overlapsWithOtherResourceFolder(AbstractJavaProjectConfigurator.java:520) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addResourceDirs(AbstractJavaProjectConfigurator.java:475) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addProjectSourceFolders(AbstractJavaProjectConfigurator.java:341) ~[na:na]
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.configure(AbstractJavaProjectConfigurator.java:156) ~[na:na]
at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:122) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda(ProjectConfigurationManager.java:511) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:153) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:505) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:443) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda(ProjectConfigurationManager.java:358) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:153) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:101) ~[na:na]
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1370) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:357) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:343) ~[na:na]
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:325) ~[na:na]
at org.eclipse.m2e.profiles.core.internal.management.ProfileManager.updateActiveProfiles(ProfileManager.java:86) ~[na:na]
at org.eclipse.m2e.profiles.ui.internal.actions.ProfileSelectionHandler$UpdateProfilesJob.runInWorkspace(ProfileSelectionHandler.java:320) ~[na:na]
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:42) ~[na:na]
我最终抓取源代码到 m2e 并调试我的 Eclipse 实例,在 AbstractJavaProjectConfigurator.getProjectRelativePath()
上设置断点以直接检查 NPE 的源代码。
原因最终是 <resource>...</resource>
元素中缺少 <directory>...</directory>
元素。我没有早点找到它,因为 m2e/Eclipse 没有发现错误的任何上下文。