apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.69k stars 853 forks source link

Maven Project unloadable [class java.util.HashMap$Node cannot be cast to class java.util.HashMap$TreeNode] #4219

Open vieiro opened 2 years ago

vieiro commented 2 years ago

Apache NetBeans version

Apache NetBeans latest daily build

What happened

While opening a Maven project with Apache NetBeans 14 some modules I got this exception:

INFO [org.netbeans.modules.maven.problems.MavenModelProblemsProvider]: Exception thrown while loading maven project at C:\[PATH_TO_MAVEN_MODULE]@4ab62a4e:92fc990
java.lang.ClassCastException: class java.util.HashMap$Node cannot be cast to class java.util.HashMap$TreeNode (java.util.HashMap$Node and java.util.HashMap$TreeNode are in module java.base of loader 'bootstrap')
    at java.base/java.util.HashMap$TreeNode.moveRootToFront(HashMap.java:1900)
    at java.base/java.util.HashMap$TreeNode.putTreeVal(HashMap.java:2079)
    at java.base/java.util.HashMap.putVal(HashMap.java:634)
    at java.base/java.util.HashMap.put(HashMap.java:608)
    at java.base/java.util.HashSet.add(HashSet.java:220)
    at org.apache.maven.model.validation.DefaultModelValidator.validateId(DefaultModelValidator.java:852)
    at org.apache.maven.model.validation.DefaultModelValidator.validateEffectiveDependency(DefaultModelValidator.java:664)
    at org.apache.maven.model.validation.DefaultModelValidator.validateEffectiveDependencies(DefaultModelValidator.java:588)
    at org.apache.maven.model.validation.DefaultModelValidator.validateEffectiveModel(DefaultModelValidator.java:378)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:564)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:454)
    at org.apache.maven.model.building.DefaultModelBuilder.importDependencyManagement(DefaultModelBuilder.java:1381)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:544)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:454)
    at org.apache.maven.model.building.DefaultModelBuilder.importDependencyManagement(DefaultModelBuilder.java:1381)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:544)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:454)
    at org.apache.maven.model.building.DefaultModelBuilder.importDependencyManagement(DefaultModelBuilder.java:1381)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:544)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:454)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:267)
    at org.netbeans.modules.maven.embedder.impl.NBModelBuilder.build(NBModelBuilder.java:53)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:293)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:538)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:523)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:410)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:362)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.process(DefaultDependencyCollector.java:349)
    at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:254)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:284)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:170)
    at org.apache.maven.project.DefaultProjectBuilder.resolveDependencies(DefaultProjectBuilder.java:227)
    at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:200)
    at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:124)
    at org.netbeans.modules.maven.embedder.MavenEmbedder.readProjectWithDependencies(MavenEmbedder.java:240)
    at org.netbeans.modules.maven.modelcache.MavenProjectCache.loadOriginalMavenProject(MavenProjectCache.java:212)
    at org.netbeans.modules.maven.modelcache.MavenProjectCache.access$100(MavenProjectCache.java:62)
    at org.netbeans.modules.maven.modelcache.MavenProjectCache$2.run(MavenProjectCache.java:107)
    at org.netbeans.modules.maven.modelcache.MavenProjectCache$2.run(MavenProjectCache.java:95)
    at org.netbeans.modules.openide.util.DefaultMutexImplementation.writeAccess(DefaultMutexImplementation.java:229)
    at org.openide.util.Mutex.writeAccess(Mutex.java:252)
    at org.netbeans.modules.maven.modelcache.MavenProjectCache.getMavenProject(MavenProjectCache.java:95)
    at org.netbeans.modules.maven.NbMavenProjectImpl.loadOriginalMavenProject(NbMavenProjectImpl.java:473)
    at org.netbeans.modules.maven.NbMavenProjectImpl.getOriginalMavenProject(NbMavenProjectImpl.java:414)
    at org.netbeans.modules.maven.api.NbMavenProject.getMavenProject(NbMavenProject.java:286)
    at org.netbeans.modules.maven.NbMavenProjectImpl$PackagingTypeDependentLookup.check(NbMavenProjectImpl.java:931)
    at org.netbeans.modules.maven.NbMavenProjectImpl$PackagingTypeDependentLookup.<init>(NbMavenProjectImpl.java:886)
    at org.netbeans.modules.maven.NbMavenProjectImpl.<init>(NbMavenProjectImpl.java:263)
    at org.netbeans.modules.maven.NbMavenProjectFactory.loadProject(NbMavenProjectFactory.java:95)
    at org.netbeans.modules.projectapi.nb.NbProjectManager.createProject(NbProjectManager.java:376)
    at org.netbeans.modules.projectapi.nb.NbProjectManager.access$300(NbProjectManager.java:69)
    at org.netbeans.modules.projectapi.nb.NbProjectManager$2.run(NbProjectManager.java:289)
    at org.netbeans.modules.projectapi.nb.NbProjectManager$2.run(NbProjectManager.java:218)
    at org.netbeans.modules.openide.util.DefaultMutexImplementation.readAccess(DefaultMutexImplementation.java:188)
    at org.openide.util.Mutex.readAccess(Mutex.java:231)
    at org.netbeans.modules.projectapi.nb.NbProjectManager.findProject(NbProjectManager.java:218)
    at org.netbeans.api.project.ProjectManager.findProject(ProjectManager.java:142)
    at org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation.getOwner(SimpleFileOwnerQueryImplementation.java:144)
    at org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation.getOwner(SimpleFileOwnerQueryImplementation.java:93)
    at org.netbeans.api.project.FileOwnerQuery.getOwner(FileOwnerQuery.java:125)
    at org.netbeans.modules.projectapi.ProjectSharabilityQuery2.getSharability(ProjectSharabilityQuery2.java:40)
    at org.netbeans.api.queries.SharabilityQuery.getSharability(SharabilityQuery.java:152)
    at org.netbeans.modules.git.utils.GitUtils.isIgnored(GitUtils.java:227)
[catch] at org.netbeans.modules.git.FileStatusCache$IgnoredFilesHandler.run(FileStatusCache.java:851)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

How to reproduce

No response

Did this work correctly in an earlier version?

Apache NetBeans 13

Operating System

Windows 10

JDK

OpenJDK Runtime Environment 11.0.15+9-LTS

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

No response

Are you willing to submit a pull request?

Yes

Code of Conduct

Yes

vieiro commented 2 years ago

NOTE: Problem is solved after a "Clean & Build".

mbien commented 2 years ago

interesting exception. I take a look.

mbien commented 2 years ago

maven.embedder, last NB code point which calls into libs: at org.netbeans.modules.maven.embedder.MavenEmbedder.readProjectWithDependencies(MavenEmbedder.java:240)

uses a fairly old (2014) version of:

A2AC1CD690AB4C80DEFE7F9BCE14D35934C35CEC jdom:jdom:1.0
5D9CE6ADD7B714B8095F0E3E396C5E9F8C5DCFEF org.apache.maven.shared:maven-dependency-tree:2.2

3.1.1 would be latest. Probably good time to bump some versions after figuring out what is compatible with what etc.

it depends on org.eclipse.aether which is also in the trace, see pom: https://search.maven.org/artifact/org.apache.maven.shared/maven-dependency-tree/3.1.1/jar I am actually not sure where the module is pulling this jar from