Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-7102

maven:repository-remove fails with NPE if ~/.m2/settings does not exist

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • 4.2.11
    • None
    • karaf
    • None
    • Karaf 4.2.11
      Java  1.8.0_282
      OS    Redhat 8.2

    Description

      Starting with a virgin Karaf 4.2.11 installation, I added my own repository and I attempted to remove the default remote repositories. 
      Removing the repository id central fails with a NPE.  Why?

      Per link Freeman:

      This is caused by that you don't have ~/.m2/settings.xml, so mavenSettings is null. We need to add a NPE guard here.

      karaf@root()> maven:repository-add -id myrepo http://myrepo.example.com
      karaf@root()> maven:repository-remove -id central 
      Are you sure to remove repository with ID "central" for URL https://repo1.maven.org/maven2/? (y/N) y 
      null 
      karaf@root()> 

      From karaf.log
      14:16:28.422 WARN [pipe-maven:repository-remove -id central] The Parser of class org.apache.karaf.shell.impl.console.ConsoleSessionImpl$$Lambda$411/734988569 does not support the CompletingParsedLine interface. Completion with escaped or quoted words won't work correctly.
      14:16:30.081 ERROR [pipe-maven:repository-remove -id central] null
      java.lang.NullPointerException: null
              at org.apache.karaf.maven.command.RepositoryRemoveCommand.edit(RepositoryRemoveCommand.java:73) ~[!/:?]
            at org.apache.karaf.maven.command.RepositoryEditCommandSupport.doAction(RepositoryEditCommandSupport.java:65) ~[!/:?]
              at org.apache.karaf.maven.command.MavenConfigurationSupport.execute(MavenConfigurationSupport.java:161) [!/:?] 
              at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84) [!/:4.2.11] 
              at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68) [!/:4.2.11]
              at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86) [!/:4.2.11] 
              at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599) [!/:4.2.11] 
              at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526) [!/:4.2.11] 
             at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415) [!/:4.2.11] 
              at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416) [!/:4.2.11] 
              at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) [!/:4.2.11] 
              at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) [!/:4.2.11] 
              at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_282] 
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_282] 
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_282] 
             at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282] 

      Paul Spencer

      Attachments

        Activity

          People

            Unassigned Unassigned
            paulsp Paul Spencer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: