Ask Your Question
0

Unable to generate .java from Yang model

asked 2017-05-08 08:17:19 -0700

thelib gravatar image

updated 2017-05-08 08:21:03 -0700

I'm trying to generate a java class from a very simple YANG file, but I can't get the code generator to work.

When I run 'mvn generate-sources' I get the following error:

Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:1.0.3-Boron-SR3:generate-sources (default) on project yangplayground: 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.ClassNotFoundException}

What am I missing?

Here's the pom:

<parent>
    <groupId>org.opendaylight.odlparent</groupId>
    <artifactId>bundle-parent</artifactId>
    <version>1.7.3-Boron-SR3</version>
    <relativePath/>
</parent>

<groupId>yangplayground</groupId>
<artifactId>yangplayground</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.opendaylight.yangtools</groupId>
            <artifactId>yangtools-artifacts</artifactId>
            <version>1.0.3-Boron-SR3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.opendaylight.mdsal</groupId>
            <artifactId>mdsal-artifacts</artifactId>
            <version>2.1.3-Boron-SR3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.opendaylight.controller</groupId>
            <artifactId>mdsal-artifacts</artifactId>
            <version>1.4.3-Boron-SR3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.opendaylight.mdsal</groupId>
            <artifactId>mdsal-binding</artifactId>
            <version>0.9.3-Boron-SR3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
    </dependency>
    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>sal-binding-api</artifactId>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>sal-binding-util</artifactId>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>sal-broker-impl</artifactId>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>sal-common-impl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>sal-common-util</artifactId>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>sal-core-api</artifactId>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.mdsal</groupId>
        <artifactId>mdsal-binding-generator-impl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.mdsal</groupId>
        <artifactId>mdsal-binding-dom-codec</artifactId>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.yangtools</groupId>
        <artifactId>yang-data-impl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.opendaylight.yangtools</groupId>
        <artifactId>yang-model-util</artifactId>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.truth</groupId>
        <artifactId>truth</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>sal-test-model</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.opendaylight.yangtools</groupId>
            <artifactId>yang-maven-plugin</artifactId>
            <version>1.0.3-Boron-SR3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate-sources</goal>
                    </goals>
                    <configuration>
                        <inspectDependencies>false</inspectDependencies>
                        <yangFilesRootDir>${project.basedir}/src/main/yang</yangFilesRootDir>
                        <codeGenerators>
                            <generator>
                                <codeGeneratorClass>
                                    org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
                                </codeGeneratorClass>
                                <outputBaseDir>${project.build.directory}/generated-sources/config</outputBaseDir>
                                <additionalConfiguration>
                                    <namespaceToPackage1>
                                        urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
                                    </namespaceToPackage1>
                                </additionalConfiguration>
                            </generator>
                            <generator>
                                <codeGeneratorClass>
                                    org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl
                                </codeGeneratorClass>
                                <outputBaseDir>${project.build.directory}/generated-sources/config1</outputBaseDir>
                            </generator>
                        </codeGenerators>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-05-08 08:55:37 -0700

thelib gravatar image

Ok, I got it I solved, I used the wrong class name (obviously from an outdated example):

instead of ...

org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl

.. I used ...

org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl

... and now everything works out as expected (classes are generated).

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2017-05-08 08:17:19 -0700

Seen: 41 times

Last updated: May 08