Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse throws NullPointerException during Maven update

I've been fighting an internal Eclipse error for two days. I'm running the latest Spring Tool Suite edition of Eclipse, and I've attempting to import a collection of existing Maven projects. Whenever I do so, Eclipse throws a NullPointerException, but no stack trace is available from the Error Log view. If I instruct Eclipse to update the Maven project (Maven > Update Project), I get a NullPointerException again. This time, the Error Log view reports the following stack trace:

java.lang.NullPointerException
    at org.eclipse.wst.common.componentcore.internal.resources.VirtualResource.getProjectRelativePaths(VirtualResource.java:119)
    at org.eclipse.wst.common.componentcore.internal.resources.VirtualFile.getUnderlyingFiles(VirtualFile.java:104)
    at org.eclipse.wst.common.componentcore.internal.resources.VirtualFile.getUnderlyingResources(VirtualFile.java:93)
    at org.eclipse.wst.common.componentcore.internal.resources.VirtualResource.exists(VirtualResource.java:88)
    at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getNonBinaryComponentManifest(ManifestUtilities.java:124)
    at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getManifest(ManifestUtilities.java:81)
    at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getManifestClasspath(ManifestUtilities.java:147)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getManifestClasspath(J2EEModuleVirtualComponent.java:248)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.calculateManifestReferences(J2EEModuleVirtualComponent.java:368)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.cacheManifestReferences(J2EEModuleVirtualComponent.java:360)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:176)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:214)
    at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:207)
    at org.eclipse.m2e.wtp.WebProjectConfiguratorDelegate.configureClasspath(WebProjectConfiguratorDelegate.java:386)
    at org.eclipse.m2e.wtp.WTPProjectConfigurator.configureClasspath(WTPProjectConfigurator.java:107)
    at org.eclipse.m2e.jdt.internal.DefaultClasspathManagerDelegate.populateClasspath(DefaultClasspathManagerDelegate.java:61)
    at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:253)
    at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:363)
    at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:343)
    at org.eclipse.m2e.jdt.internal.BuildPathManager.getClasspath(BuildPathManager.java:371)
    at org.eclipse.m2e.jdt.internal.BuildPathManager.updateClasspath(BuildPathManager.java:191)
    at org.eclipse.m2e.jdt.internal.BuildPathManager.mavenProjectChanged(BuildPathManager.java:180)
    at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.notifyProjectChangeListeners(ProjectRegistryManager.java:746)
    at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.applyMutableProjectRegistry(ProjectRegistryManager.java:865)
    at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:289)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:369)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:316)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:1)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:161)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:137)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:89)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1301)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:313)
    at org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob.runInWorkspace(UpdateMavenProjectJob.java:77)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

Here's what I've tried:

  • I've blown away my workspace and created a new one. Multiple times.
  • I've blown away my Maven repository so that it would be re-created.
  • I've reinstalled Spring Tool Suite.
  • I've tried asking Eclipse to update the Maven repositories.
  • I've checked for merge conflicts in my local SVN repository. (There are none; this is a brand new branch from trunk that is freshly checked out.)
  • I've checked the Synchronize view in Eclipse to see if it notes any differences. (Eclipse can't get far enough to recognize any projects available to synchronize.)
  • I've searched Google for NullPointerExceptions occurring in VirtualResource.getProjectRelativePaths(). I've found NullPointerExceptions in other very similar places, and I've tried the recommendations for them, just for the heck of it, but none of them work.

I'm at my wits' end with this problem. Help me, Obi-Wan Kenobi, you are my only hope.

like image 882
Robert J. Walker Avatar asked Nov 04 '13 23:11

Robert J. Walker


People also ask

How do I fix NullPointerException in eclipse?

NullPointerException is thrown when a reference variable is accessed (or de-referenced) and is not pointing to any object. This error can be resolved by using a try-catch block or an if-else condition to check if a reference variable is null before dereferencing it.

What is NullPointerException in eclipse?

NullPointerException is a runtime exception in Java that occurs when a variable is accessed which is not pointing to any object and refers to nothing or null. Since the NullPointerException is a runtime exception, it doesn't need to be caught and handled explicitly in application code.

How do I overcome NullPointerException?

How to avoid the NullPointerException? To avoid the NullPointerException, we must ensure that all the objects are initialized properly, before you use them. When we declare a reference variable, we must verify that object is not null, before we request a method or a field from the objects.

What is Mvn Eclipse Eclipse command?

You can use Maven to set up the files needed for eclipse: mvn eclipse:eclipse. This will produce the following files for each module: . classpath file.


2 Answers

This is what I did to fix it:

  1. Removed the project from the workspace
  2. Remove .classpath, .project and .settings folder
  3. Reimport the project
like image 110
genjosanzo Avatar answered Oct 10 '22 15:10

genjosanzo


I'm strongly sure that the problem is not related to the maven plugin; but if it is, i was wandering if you run a mvn eclipse:eclipse before importing the project into eclipse, if you do that and you are using maven 3, I had checked that maven plugin does not support maven 3 properly yet; so I encourage you to make a mvn eclipse:clean, then import the project as an existing project, and after that activate the maven plugin nature from eclipse. I hope it helps,

PS. it seems to be a know eclipse bug (https://www.google.com.uy/search?q=j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java&oq=j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java&aqs=chrome..69i57.128j0j7&sourceid=chrome&espv=210&es_sm=91&ie=UTF-8); try downloading the last eclipse version; I'm using kepler at work, and I'm working in maven/spring projects and it works fine.

Good luck!

like image 43
echinelli Avatar answered Oct 10 '22 16:10

echinelli