Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-5680

java.lang.UnsupportedOperationException on DefaultProjectBuilder.build

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 3.2.3
    • 3.2.5
    • Bootstrap & Build
    • None

    Description

      ProjectBuildingRequest request = ...
      ProjectBuilder builder = plexus.lookup(ProjectBuilder.class);
      builder.build(file, request);
      

      When the build method is called, the following exception is thrown:

      java.lang.UnsupportedOperationException
      	at java.util.AbstractMap.put(AbstractMap.java:209)
      	at org.apache.maven.project.DefaultProjectBuilder.initProject(DefaultProjectBuilder.java:815)
      	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:174)
      	at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:118)
      

      The code should be reviewed. This is the offending code inside DefaultProjectBuilder:

                          Artifact artifact = repositorySystem.createDependencyArtifact( d );
      
                          if ( artifact == null )
                          {
                              map = Collections.emptyMap();
                          }
      
                          map.put( d.getManagementKey(), artifact );
      
      

      Attachments

        1. pom.xml
          2 kB
          George Gastaldi

        Issue Links

          Activity

            Raising the priority, since DefaultProjectBuilder is unusable without fixing this

            gastaldi George Gastaldi added a comment - Raising the priority, since DefaultProjectBuilder is unusable without fixing this

            pom.xml to reproduce problem attached

            gastaldi George Gastaldi added a comment - pom.xml to reproduce problem attached

            To reproduce, run mvn clean install in the attached pom.xml

            gastaldi George Gastaldi added a comment - To reproduce, run mvn clean install in the attached pom.xml

            This error doesn't happen in 3.2.2 and earlier versions

            gastaldi George Gastaldi added a comment - This error doesn't happen in 3.2.2 and earlier versions
            selliott@paml.com Shaun added a comment -

            gastaldi can you post your environment information, such as operating system, jdk, etc? You can get this with "mvn --version". Also, are you by chance using homebrew?

            selliott@paml.com Shaun added a comment - gastaldi can you post your environment information, such as operating system, jdk, etc? You can get this with "mvn --version". Also, are you by chance using homebrew?
            selliott@paml.com Shaun added a comment -

            I'm linking this to MNG-5368, it looks like they could be related.

            selliott@paml.com Shaun added a comment - I'm linking this to MNG-5368 , it looks like they could be related.

            I am using Fedora 20, running on Maven 3.2.3 on JDK 1.8.0_11. I am not using homebrew

            gastaldi George Gastaldi added a comment - I am using Fedora 20, running on Maven 3.2.3 on JDK 1.8.0_11. I am not using homebrew

            Yes, it looks like a duplicate of MNG-5368, it should be reopened and fixed

            gastaldi George Gastaldi added a comment - Yes, it looks like a duplicate of MNG-5368 , it should be reopened and fixed
            selliott@paml.com Shaun added a comment -

            I had a colleague who was having this same issue, MNG-5368 was definitely the cause. It would be an improvement for maven to give some sensible error rather than it manifesting in this way.

            FWIW, it was not environmental issues, but here was his settings:

            username-mbp112:bin username$ mvn --version
            Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T13:58:10-07:00)
            Maven home: /usr/share/java/apache-maven-3.2.3
            Java version: 1.7.0_45, vendor: Oracle Corporation
            Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
            Default locale: en_US, platform encoding: UTF-8
            OS name: "mac os x", version: "10.10.1", arch: "x86_64", family: "mac"
            
            selliott@paml.com Shaun added a comment - I had a colleague who was having this same issue, MNG-5368 was definitely the cause. It would be an improvement for maven to give some sensible error rather than it manifesting in this way. FWIW, it was not environmental issues, but here was his settings: username-mbp112:bin username$ mvn --version Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T13:58:10-07:00) Maven home: /usr/share/java/apache-maven-3.2.3 Java version: 1.7.0_45, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.10.1", arch: "x86_64", family: "mac"
            joe@kafsemo.org Joseph Walton added a comment -

            It looks like this commit in 3.2.4 for MNG-5727 may fix this.

            joe@kafsemo.org Joseph Walton added a comment - It looks like this commit in 3.2.4 for MNG-5727 may fix this.

            People

              schulte77 Christian Schulte
              gastaldi George Gastaldi
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: