Ask Your Question
0

NullPointerException when generating java source code from yang model

asked 2015-05-16 11:41:11 -0700

Denis gravatar image

updated 2015-05-17 04:10:09 -0700

Hi,

I'm following the steps of Toaster:Step-By-Step tutorial. At generating java source code from yang model, npe gets thrown.. (full stack trace, some parts ommitted)

[ERROR] yang-to-sources: Unable to parse yang files from /home/luna/Desktop/odl-testapp/MedQos/MedQos/src/main/yang
java.lang.NullPointerException
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.resolveIdentity(YangParserImpl.java:1039)
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.resolveIdentities(YangParserImpl.java:1019)
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.build(YangParserImpl.java:711)

.....

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.466 s
[INFO] Finished at: 2015-05-16T20:29:01+02:00
[INFO] Final Memory: 15M/331M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:0.6.5-Helium-SR3:generate-sources (default) on project MedQos: yang-to-sources: Unable to parse yang files from /home/luna/Desktop/odl-testapp/MedQos/MedQos/src/main/yang: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:0.6.5-Helium-SR3:generate-sources (default) on project MedQos: yang-to-sources: Unable to parse yang files from /home/luna/Desktop/odl-testapp/MedQos/MedQos/src/main/yang
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)

....

Caused by: org.apache.maven.plugin.MojoExecutionException: yang-to-sources: Unable to parse yang files from /home/luna/Desktop/odl-testapp/MedQos/MedQos/src/main/yang
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.processYang(YangToSourcesProcessor.java:177)
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:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: java.lang.NullPointerException
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.resolveIdentity(YangParserImpl.java:1039)
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.resolveIdentities(YangParserImpl.java:1019)
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.build(YangParserImpl.java:711)
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.parseYangModelSources(YangParserImpl.java:354)
at org.opendaylight.yangtools.yang.parser.impl.YangParserImpl.parseYangModelsFromStreamsMapped(YangParserImpl.java:308)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.processYang(YangToSourcesProcessor.java:151)
... 24 more

Does anyone know, how to resolve this ?

Heres my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
  <artifactId>MedQos-parent</artifactId>
  <groupId>com.mygroup.own</groupId>
  <version>0.0.1-SNAPSHOT</version>
  <relativePath>../</relativePath>
</parent>

<artifactId>MedQos</artifactId>
<packaging>jar</packaging>

<build>
  <plugins>
     <plugin>
         <groupId>org.opendaylight.yangtools</groupId>
         <artifactId>yang-maven-plugin</artifactId>
         <version>${yangtools.version}</version>
     <executions>
       <execution>
          <goals>
             <goal>generate-sources</goal>
          </goals>
          <configuration>
             <yangFilesRootDir>src/main/yang</yangFilesRootDir>
          <codeGenerators>
             <generator>
                 <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
             <outputBaseDir>${salGeneratorPath}</outputBaseDir>
           </generator>
         </codeGenerators>
         <inspectDependencies>true</inspectDependencies>
       </configuration>
     </execution>
   </executions>
   <dependencies>
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>maven-sal-api-gen-plugin</artifactId>
       <version>${yangtools ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-08-05 04:32:26 -0700

happysmile gravatar image

I had the same problem.This solved my problem:

  <parent>
    <groupId>org.opendaylight.yangtools</groupId>
    <artifactId>binding-parent</artifactId>
    <version>0.7.0-SNAPSHOT</version>
    <relativePath/>
  </parent>

By using parent all dependencies are inherited from parent! link

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2015-05-16 11:41:11 -0700

Seen: 529 times

Last updated: Aug 05 '15