Ask is moving to Stack Overflow and! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode


yang-to-sources : javaType cannot be null

asked 2016-06-08 08:36:42 -0700

yanboyuan gravatar image

When I try to translate yang files defined by ietf about ietf-yang-types to java files, I encountered such problem:

[ERROR] yang-to-sources: Unable to generate sources with org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl generator 
java.lang.NullPointerException: javaType cannot be null
at org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl.wrapJavaTypeIntoTO(

After this, I try to locate the faults, and write a demo:

module ietf-yang-types {

namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types"; prefix "yang";

organization "IETF NETMOD (NETCONF Data Modeling Language) Working Group";

contact "";

description "This module.";

revision 2010-09-24 { description "Initial revision."; reference "RFC 6021: Common YANG Data Types"; }

/* collection of counter and gauge types */

typedef counter32 { type uint32; description "The"; reference "RFC 2578: Structure of Management Information Version 2 (SMIv2)"; }

typedef zero-based-counter32 { type yang:counter32; default "0"; description "The."; reference "RFC 4502: Remote Network Monitoring Management Information Base Version 2"; } }

I notice that when there is no typedef-calling-another-type, such as zero-based-counter32 referenced count32, NullPointException happened.

I am confused about how to fix this problem, I got nothing until now. Could anybody help me ? I will be appreciated.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-06-10 12:10:18 -0700

updated 2016-06-15 10:15:04 -0700

I have used the your example and I am able to generate the java code without any issue:

typedef counter32
    type uint32;

typedef zero-based-counter{
    type router:counter32;

Generate java code

public class Counter32
 implements Serializable {...}

public class ZeroBasedCounter extends Counter32
 implements Serializable {...}
edit flag offensive delete publish link more


The version doesn't match. After changed yangtools's version, compiling succeeds.Thx

yanboyuan ( 2016-06-15 03:02:13 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-06-08 08:36:42 -0700

Seen: 100 times

Last updated: Jun 15 '16