简体   繁体   中英

OpenDaylight Yangtools codeGeneratorClass for CodeGenerator cannot be null

I am able to generate Pojos from Yang files using opendaylight yangtools. however i constantly get this error after generation finishes after mvn generate-sources or mvn clean build:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.816 s
[INFO] Finished at: 2018-07-22T10:09:59+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources (default) on project odl-yang-generator-poc: Execution default of goal org.opendaylight.yangtools:yang-maven-plugin:2.0.8-SNAPSHOT:generate-sources failed: codeGeneratorClass for CodeGenerator cannot be null

Caused by: java.lang.NullPointerException: codeGeneratorClass for CodeGenerator cannot be null
    at com.google.common.base.Preconditions.checkNotNull (Preconditions.java:900)
    at org.opendaylight.yangtools.yang2sources.plugin.ConfigArg$CodeGeneratorArg.check (ConfigArg.java:71)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.instantiateGenerators (YangToSourcesProcessor.java:219)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.conditionalExecute (YangToSourcesProcessor.java:135)
    at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesMojo.execute (YangToSourcesMojo.java:123)

here is my pom:

<parent>
        <groupId>org.opendaylight.mdsal</groupId>
        <artifactId>binding-parent</artifactId>
        <version>0.13.0-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <build>
    <plugins>
            <plugin>
                <groupId>org.opendaylight.yangtools</groupId>
                <artifactId>yang-maven-plugin</artifactId>
                <version>2.0.8-SNAPSHOT</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate-sources</goal>
                        </goals>
                        <configuration>
                            <yangFilesRootDir>src/main/yang</yangFilesRootDir>
                                <codeGenerators>
                                <generator>
                                        org.opendaylight.mdsal.maven.sal.api.gen.plugin.CodeGeneratorImpl
                                    <outputBaseDir>
                                        target/generated-sources
                                    </outputBaseDir>
                                </generator>
                                </codeGenerators>
                            <inspectDependencies>true</inspectDependencies>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.opendaylight.mdsal</groupId>
                        <artifactId>maven-sal-api-gen-plugin</artifactId>
                        <version>0.13.0-SNAPSHOT</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

Obviously the generator is found since the files are generated. what is causing the exception?

org.opendaylight.mdsal.maven.sal.api.gen.plugin.CodeGeneratorImpl is incorrect - it should be org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl.

However you are deriving your pom from binding-parent so you don't need to re-define the yang-maven plugin at all as it is already defined/provided by binding-parent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM