Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-271

NullPointerException is thrown by yang-maven-plugin when the imported module is missing

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • None
    • None
    • Operating System: Linux
      Platform: PC

    • 1578

    Description

      When yang-maven-plugin is not able to find module imported from yang file then NPE is thrown. There is no information about the root cause of the problem.

      How to reproduce:
      1. Create yang file which uses config module like:
      module producer {
      yang-version 1;
      namespace "urn:amartus:odl:test:config:producer";
      prefix prod;

      import config

      { prefix config; revision-date 2013-04-05; }

      description "Producer service definition";

      revision 2014-08-13

      { description "Initial revision"; }

      identity producer

      { description "Producer service"; base "config:service-type"; config:java-class "com.amartus.odl.test.config.producer.Producer"; }

      }

      2. Do not add required dependency in maven configuration

      <dependency>
      <groupId>org.opendaylight.controller</groupId>
      <artifactId>config-api</artifactId>
      </dependency>

      3. run mvn clean install

      Following exception is reported:

      [INFO] — yang-maven-plugin:0.6.2-SNAPSHOT:generate-sources (default) @ producer-model —
      [INFO] yang-to-sources: Inspecting /home/dariusz/work/opendaylight/git/storm-yang/playground/odl-yang-config/producer-model/src/main/yang
      [INFO] yang-to-sources: Searching for yang files in following dependencies: []
      [INFO] yang-to-sources: Searching for yang files in following dependencies: []
      [ERROR] yang-to-sources: Unable to parse yang files from /home/dariusz/work/opendaylight/git/storm-yang/playground/odl-yang-config/producer-model/src/main/yang
      java.lang.NullPointerException
      at org.opendaylight.yangtools.yang.parser.impl.YangParserListenerImpl.parseQName(YangParserListenerImpl.java:585)
      at org.opendaylight.yangtools.yang.parser.impl.YangParserListenerImpl.handleUnknownNode(YangParserListenerImpl.java:1143)
      at org.opendaylight.yangtools.yang.parser.impl.YangParserListenerImpl.enterIdentifier_stmt(YangParserListenerImpl.java:925)
      at org.opendaylight.yangtools.antlrv4.code.gen.YangParser$Identifier_stmtContext.enterRule(YangParser.java:279)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.enterRule(ParseTreeWalker.java:66)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:49)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
      at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.parseSourcesToBuilders(YangParserImpl.java:405)
      at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.resolveSources(YangParserImpl.java:378)
      at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.parseYangModelSources(YangParserImpl.java:350)
      at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.parseYangModelsFromStreamsMapped(YangParserImpl.java:308)
      at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.processYang(YangToSourcesProcessor.java:151)
      at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.execute(YangToSourcesProcessor.java:82)
      at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesMojo.execute(YangToSourcesMojo.java:122)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

      It would be nice to have information which module is missing instead.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mvitez@cisco.com Martin Vitez
            dariusz.a.nowak@wp.pl Dariusz Nowak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: