Ask Your Question
0

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 com.google.common.base.Preconditions.checkNotNull(Preconditions.java:226)
at org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl.wrapJavaTypeIntoTO(TypeProviderImpl.java:759)

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 " j.schoenwaelder@jacobs-university.de";

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
0

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

Comments

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

Follow
1 follower

Stats

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

Seen: 82 times

Last updated: Jun 15 '16