[CONTROLLER-679] Restconf cannot deserialize leaf whose type is defined in another module Created: 12/Aug/14  Updated: 25/Jul/23  Resolved: 14/Aug/14

Status: Resolved
Project: controller
Component/s: mdsal
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Ashwin Pankaj Assignee: Ashwin Pankaj
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


Attachments: PNG File stack_trace.png    
External issue ID: 1528

 Description   

Define two yang models as follows

types.yang
==============

module types {
namespace
"urn:ping:params:xml:ns:yang:types";
prefix
"types";

description
"Types and Groupings";

revision 2014-07-05

{ description "Initial version."; }

typedef Name {
type string { length "1..64"; }
description
"This data type is used to model a name ";
}
}

test.yang
========

module test {
namespace
"urn:ping:params:xml:ns:yang:test";
prefix
"test";
import types { prefix "types"; }
description
"Test ";

revision 2014-07-05 { description "Initial version."; }

container test-container {
leaf test-name

{ type test:Name; }

}
}

Now try to set via restconf -
<test-container>
<test-name>Blah
</test-name>
<test-container>

org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils.loadClass fails with java.lang.ClassNotFoundException. This is because SAl is searching the package of "test" for "types" class.



 Comments   
Comment by Jozef Gloncak [ 12/Aug/14 ]

I am just guessing. Couldn't be problem that you are reffering module types in module test via incorrect prefix (test:Name instead of types:Name)

container test-container {
leaf test-name

{ type test:Name; }

}

Comment by Ashwin Pankaj [ 12/Aug/14 ]

That was a typo.

Comment by Jozef Gloncak [ 12/Aug/14 ]

(In reply to Ashwin Pankaj from comment #2)
> That was a typo.

does it mean that now it is ok or that it was typo here in bugzila and problem still exist?

Comment by Jan Hajnar [ 12/Aug/14 ]

Hi,

After trying with today's build (August 12th) and correcting errors in your input and model:
type test:Name -> type types:Name,
last line of input <test-container> -> </test-container>
everything works as expected.

path:
PUT http://localhost:8080/restconf/config/test:test-container/
data:
<test-container>
<test-name>Blah
</test-name>
</test-container>

path:
GET http://localhost:8080/restconf/config/test:test-container/
returns
<test-container xmlns="urn:ping:params:xml:ns:yang:test">
<test-name>Blah</test-name>
</test-container>

Please provide feedback if this issue is fixed or still persists.

Comment by Ashwin Pankaj [ 13/Aug/14 ]

I am sorry I forgot to add one important detail - the exception occurs when a registered org.opendaylight,controller.md.sal.binding.api.DataChangelistener tries to retrieve the updates to the config store using getupdatedData.

I have attached a sample stack trace.

Comment by Ashwin Pankaj [ 13/Aug/14 ]

Attachment stack_trace.png has been added with description: stack trace

Comment by Ashwin Pankaj [ 14/Aug/14 ]

The method suggested by Jan works for me.

I was using DataBroker SAL service to register for changes. This would trigger events but I was not able to get updated data.

The fix is to implement dataChangeListener as mentioned in https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Toaster_Step-By-Step

Generated at Wed Feb 07 19:53:37 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.