[MDSAL-423] Failed to find leafref target Created: 18/Feb/19  Updated: 22/Dec/19  Resolved: 18/Mar/19

Status: Resolved
Project: mdsal
Component/s: Binding codegen
Affects Version/s: Carbon SR4, 3.0.6
Fix Version/s: None

Type: Bug Priority: High
Reporter: Selvakumar Kanniappan Assignee: Robert Varga
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Eclipse IDE for Java Developers

Version: 2018-09 (4.9.0)


Attachments: File etsi-nfv-common.yang     File etsi-nfv-ns.yang     File etsi-nfv-pnf.yang     File etsi-nfv-vnf.yang     File etsi-nfv.yang    
Issue Links:
Duplicate
duplicates MDSAL-182 Java binding v1: leafref up two conta... Resolved
Relates
relates to YANGTOOLS-968 Add support for RFC7950 Errata 5617 l... Resolved
relates to YANGTOOLS-1050 Leafref resolution breaks down on lea... Resolved
Priority: High

 Description   

Team,

I am facing an issue  related to "Failed to find leafref target"  when trying to generate java classes using org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl. It would be very helpful if you could review this issue at the earliest and suggest a way to resolve this. Thank you in advance.

Attached below is the snippet of pom.xml that I had used for generating the java classes:

 

<dependencies> 
 <dependency>
 <groupId>org.opendaylight.yangtools</groupId>
 <artifactId>yang-common</artifactId>
 <version>1.1.4-Carbon</version>
 </dependency>
 <dependency>
 <groupId>org.opendaylight.yangtools</groupId>
 <artifactId>yang-model-api</artifactId>
 <version>1.1.4-Carbon</version>
 </dependency>
 <dependency>
 <groupId>org.opendaylight.yangtools</groupId>
 <artifactId>yang-data-api</artifactId>
 <version>1.1.4-Carbon</version>
 </dependency>
 <dependency>
 <groupId>org.opendaylight.yangtools</groupId>
 <artifactId>yang-data-codec-gson</artifactId>
 <version>1.1.4-Carbon</version>
 </dependency> 
 <dependency>
 <groupId>org.opendaylight.mdsal</groupId>
 <artifactId>mdsal-binding-dom-codec</artifactId>
 <version>3.0.6</version>
 </dependency> 
 <dependency>
 <groupId>org.opendaylight.mdsal</groupId>
 <artifactId>mdsal-binding-generator-impl</artifactId>
 <version>1.0.6</version>
 </dependency> 
 <dependency>
 <groupId>org.opendaylight.mdsal.model</groupId>
 <artifactId>ietf-topology</artifactId>
 <version>2013.10.21.11.0</version>
 </dependency> 
 <dependency>
 <groupId>org.opendaylight.yangtools.model</groupId>
 <artifactId>ietf-inet-types</artifactId>
 <version>2010.09.24.7.4-Lithium-SR4</version>
 </dependency> 
 <dependency>
 <groupId>org.opendaylight.yangtools.model</groupId>
 <artifactId>ietf-yang-types</artifactId>
 <version>2010.09.24.7.4-Lithium-SR4</version>
 </dependency> 
 </dependencies>
 
<build>
 <plugins>
 <plugin>
 <groupId>org.opendaylight.yangtools</groupId>
 <artifactId>yang-maven-plugin</artifactId>
 <version>2.1.0</version>
 <executions>
 <execution>
 <goals>
 <goal>generate-sources</goal>
 </goals>
 <configuration>
 <yangFilesRootDir>src/main/yang</yangFilesRootDir>
 <codeGenerators>
 <generator> 
 <codeGeneratorClass>
 org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl
 </codeGeneratorClass>
 <outputBaseDir>
 target/generated-sources/sal
 </outputBaseDir>
 </generator>
 </codeGenerators>
 <inspectDependencies>true</inspectDependencies>
 </configuration>
 </execution>
 </executions>
 <dependencies>
 <dependency>
 <groupId>org.opendaylight.mdsal</groupId>
 <artifactId>maven-sal-api-gen-plugin</artifactId>
 <version>1.0.6</version>
 <type>jar</type>
 </dependency> 
 </dependencies>
 </plugin>
 <plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>build-helper-maven-plugin</artifactId>
 <executions>
 <execution>
 <phase>generate-sources</phase>
 <goals>
 <goal>add-source</goal>
 </goals>
 <configuration>
 <sources>
 <source>target/generated-sources/sal</source>
 </sources>
 </configuration>
 </execution>
 </executions>
 </plugin>
 </plugins>
 <pluginManagement>
 <plugins>
 <plugin>
 <groupId>org.eclipse.m2e</groupId>
 <artifactId>lifecycle-mapping</artifactId>
 <version>1.0.0</version>
 <configuration>
 <lifecycleMappingMetadata>
 <pluginExecutions>
 <pluginExecution>
 <pluginExecutionFilter>
 <groupId>
 org.opendaylight.controller
 </groupId>
 <artifactId>
 yang-maven-plugin
 </artifactId>
 <versionRange>
 [0.5,)
 </versionRange>
 <goals>
 <goal>
 generate-sources
 </goal>
 </goals>
 </pluginExecutionFilter>
 <action>
 <ignore></ignore>
 </action>
 </pluginExecution>
 </pluginExecutions>
 </lifecycleMappingMetadata>
 </configuration>
 </plugin>
 </plugins>
 </pluginManagement>
 </build>

 

 

== mvn clean install log snippet ==

ERROR] yang-to-sources: Unable to generate sources with org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl generator
 java.lang.IllegalArgumentException: Failed to find leafref target: ../../../nfv:ext-cpd/nfv:id in module etsi-nfv (QNameModule{ns=urn:etsi:params:xml:ns:yang:etsi-nfv, rev=2018-06-13})
 at com.google.common.base.Preconditions.checkArgument(Preconditions.java:458)
 at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.provideTypeForLeafref(AbstractTypeProvider.java:515)
 at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForLeafrefOrIdentityRef(AbstractTypeProvider.java:296)
 at org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider.javaTypeForSchemaDefinitionType(AbstractTypeProvider.java:191)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.resolveLeafSchemaNodeAsMethod(AbstractTypeGenerator.java:1313)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.addSchemaNodeToBuilderAsMethod(AbstractTypeGenerator.java:1032)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.resolveDataSchemaNodes(AbstractTypeGenerator.java:986)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.generateTypesFromChoiceCases(AbstractTypeGenerator.java:1142)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.choiceToGeneratedType(AbstractTypeGenerator.java:1078)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.addSchemaNodeToListBuilders(AbstractTypeGenerator.java:1732)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.listToGenType(AbstractTypeGenerator.java:320)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.addSchemaNodeToListBuilders(AbstractTypeGenerator.java:1734)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.listToGenType(AbstractTypeGenerator.java:320)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.addSchemaNodeToListBuilders(AbstractTypeGenerator.java:1734)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.listToGenType(AbstractTypeGenerator.java:320)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.addSchemaNodeToBuilderAsMethod(AbstractTypeGenerator.java:1038)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.resolveDataSchemaNodes(AbstractTypeGenerator.java:986)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.groupingsToGenTypes(AbstractTypeGenerator.java:690)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.moduleToGenTypes(AbstractTypeGenerator.java:224)
 at org.opendaylight.mdsal.binding.generator.impl.AbstractTypeGenerator.<init>(AbstractTypeGenerator.java:193)
 at org.opendaylight.mdsal.binding.generator.impl.CodegenTypeGenerator.<init>(CodegenTypeGenerator.java:32)
 at org.opendaylight.mdsal.binding.generator.impl.BindingGeneratorImpl.generateTypes(BindingGeneratorImpl.java:64)
 at org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl.generateSources(CodeGeneratorImpl.java:69)
 at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.generateSourcesWithOneGenerator(YangToSourcesProcessor.java:382)
 at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.generateSources(YangToSourcesProcessor.java:331)
 at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.conditionalExecute(YangToSourcesProcessor.java:158)
 at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesMojo.execute(YangToSourcesMojo.java:126)
 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
 at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
 at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
 at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
 at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
 at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
 [ERROR] yang-to-sources: One or more code generators failed, including failed list(generatorClass=exception) {org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl=java.lang.IllegalArgumentException}

 



 Comments   
Comment by Robert Varga [ 18/Feb/19 ]

Can you provide the models involved?

Comment by Selvakumar Kanniappan [ 18/Feb/19 ]

Yes please. Thank you. Attached with this Jira issue are the ETSI-NFV YANG models that I used for generating java classes.

etsi-nfv.yang

Comment by Robert Varga [ 20/Feb/19 ]

Thanks. The pom.xml is quite thoroughly mixed-versions, (Lithium-SR4, Carbon-SR4, Neon), I suggest you invest some time into bringing it into a consistent set

The models seem to trigger multiple problems, I will need to take some time to analyze them and file separate issues.

Comment by Robert Varga [ 20/Feb/19 ]

selvakann what is the authoritative source of the models? They do not contain copyright, hence I am not sure what I can include and what not.

Comment by Selvakumar Kanniappan [ 20/Feb/19 ]

rovarga I downloaded a copy of these  YANG models (NFV-SOL006v010.zip) from https://docbox.etsi.org/isg/nfv/open/drafts/SOL006_YANG_based_NFV_Descriptors_spec 

Comment by Selvakumar Kanniappan [ 20/Feb/19 ]

rovargaThank you so much for the time you have taken in reviewing this pom.xml and also providing your review comments. 

Yes please. I would invest some time to make it consistent with a particular SR as much as possible. To be honest, as part of my previous attempt(s) I tried a lot with various permutation & combinations to arrive at this pom.xml content; somehow I was facing one or other issue that kept me in not reaching up to this stage.

However as you suggested, I would try to make it consistent across by trying to use a specific release where possible please. Thanks again.

Comment by Selvakumar Kanniappan [ 28/Feb/19 ]

rovarga Any suggestions or updates on the issue please?  Thank you.

Comment by Selvakumar Kanniappan [ 06/Mar/19 ]

rovarga I am sure you are looking into this issue. Any insight could help us to plan for adopting the tool in our applications. Thank you in advance.

Comment by Robert Varga [ 07/Mar/19 ]

As a workaround you can add prepend "../../" to the two leafrefs which fail with this issue. That will cause the build to fail on another leafref, which has deref() method. I suggest switching the type to string for now.

Comment by Robert Varga [ 07/Mar/19 ]

Sorry, I am tied down with yangtools-3.0.0 stuff, so this has to take a back seat for another 2 weeks I estimate – it does require a complete context switch.

Comment by Robert Varga [ 17/Mar/19 ]

Looks like a duplicate, let's fix MDSAL-182 first and see where that leads us.

Comment by Robert Varga [ 18/Mar/19 ]

Confirmed, fixing MDSAL-182 fixes the reported issue.

Comment by Robert Varga [ 19/Mar/19 ]

The deref() call in the model is invalid according to RFC7950, section 9.2.2 and section 14 (see rule path-arg-str, which only allows current() function invocation).

Comment by Robert Varga [ 19/Mar/19 ]

There is a technical errata filed to support it: https://www.rfc-editor.org/errata/eid5617 , but based on the mailing this discussion it is probably going to be rejected.

Generated at Wed Feb 07 20:09:46 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.