Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9404

NoClassDefFoundError: picocli/CommandLine$ParameterException in scripts after update to Groovy 3.0.0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Information Provided
    • 3.0.0
    • None
    • None
    • Linux

    Description

      After update from Groovy 2.5.x to 3.0.0, scripts using picocli are failing with the following error:

      NoClassDefFoundError: picocli/CommandLine$ParameterException

      Here's a small example showing the problem:

      import groovy.cli.picocli.CliBuilder
      
      def cli = new CliBuilder(name: 'cliTest.groovy')
      cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show usage information')
      cli.c(type: String, longOpt: 'config', required: true, args: 1, 'Path to config file (required)')
      def opts = cli.parse(args)
      opts || System.exit(1)
      if(opts.h) {
        cli.usage()
        System.exit(0)
      }
      
      println(opts.c)
      

      Running this with Groovy 2.5.7 works:

      % ~/tmp/groovy-2.5.7/bin/groovy ./cliTest.groovy -c data/config_prod.yaml 
      data/config_prod.yaml

      But with 3.0.0, it does not:

      % ~/tmp/groovy-3.0.0/bin/groovy ./cliTest.groovy -c data/config_prod.yaml
      Caught: java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException
      java.lang.NoClassDefFoundError: picocli/CommandLine$ParameterException
              at cliTest.run(cliTest.groovy:4)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      Caused by: java.lang.ClassNotFoundException: picocli.CommandLine$ParameterException
              ... 4 more

      Attachments

        Activity

          People

            Unassigned Unassigned
            dheinric Dirk Heinrichs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: