Yang模块使用yangtools进行解析失败

时间:2017-10-03 15:10:14

标签: java maven opendaylight ietf-netconf

我使用opendaylight.yangtools来解析我的应用程序中的Yang Module文件,我只想获取一些信息,而不是实例化或使用它。

我向我的Maven pom.xml添加了这个依赖项:

<!-- opendaylight Yangtools -->
<dependency>
    <groupId>org.opendaylight.yangtools</groupId>
    <artifactId>yang-parser-impl</artifactId>
    <version>1.2.0-SNAPSHOT</version>
    <type>jar</type>
</dependency>        
<dependency>
    <groupId>org.opendaylight.yangtools</groupId>
    <artifactId>yang-parser-api</artifactId>
    <version>1.2.0-SNAPSHOT</version>
    <type>jar</type>
</dependency>
<dependency>
    <groupId>org.opendaylight.yangtools</groupId>
    <artifactId>yang-model-api</artifactId>
    <version>1.2.0-SNAPSHOT</version>
    <type>jar</type>
</dependency>

然后我创建了一个用于实现解析函数的类:

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class YangParser {

    private static final Logger LOGGER = LoggerFactory.getLogger(YangParser.class);

    public YangParser() {    
    }

    public void parseModule(String file) throws IOException, YangSyntaxErrorException {   
        LOGGER.debug("Parse Yang module from file : " + file);

        try {
            File yang_file = new File(file);
            CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();            
            reactor.addSource(YangStatementStreamSource.create(
                YangTextSchemaSource.forFile(yang_file)));

            SchemaContext schemaContext = reactor.buildEffective();            

            Set<Module> modules = schemaContext.getModules();
            for (Module m : modules) {
                LOGGER.debug("Add YANG module : " + m.getName());
                LOGGER.debug("Namespace : " + m.getNamespace().toString());
            }

        }
        catch (ReactorException e) {
            throw new IllegalStateException("Parsing Yang module failed, error : " + e.getMessage());
        }
    }
}

然后我在POST API的控制器中使用此函数来上传yang文件并解析它。 上传简单的Yang文件时:

// Contents of "acme-system.yang"
module acme-system {
 namespace "http://acme.example.com/system";
 prefix "acme";

 organization "ACME Inc.";
 contact "joe@acme.example.com";
 description
     "The module for entities implementing the ACME system.";

 revision 2007-06-09 {
     description "Initial revision.";
 }

 container system {
     leaf host-name {
         type string;
         description "Hostname for this system";
     }

     leaf-list domain-search {
         type string;
         description "List of domain names to search";
     }

     container login {
         leaf message {
             type string;
             description
                 "Message given at start of login session";
         }

         list user {
             key "name";
             leaf name {
                 type string;
             }
             leaf full-name {
                 type string;
             }
             leaf class {
                 type string;
             }
         }
     }
 }
}

我有一个成功的回应机构:

<name>acme-system</name>
<namespace>http://acme.example.com/system</namespace>
<description>The module for entities implementing the ACME system.</description>
<reference/>
<organization>ACME Inc.</organization>
<contact>joe@acme.example.com</contact>
<revision>1181340000000</revision>
<yangVersion>1</yangVersion>

当我上传一个带有导入定义的Yang文件时,我有一个不成功的响应体,出现此错误:

Parsing Yang module failed, error : Some of SOURCE_PRE_LINKAGE modifiers for statements were not resolved.

这些是日志:

DEBUG [http-nio-8080-exec-25] s.d.s.w.PropertySourcedRequestMappingHandlerMapping.getHandlerInternal(306) | Looking up handler method for path /ems/2.0/file/parser
DEBUG [http-nio-8080-exec-25] s.d.s.w.PropertySourcedRequestMappingHandlerMapping.lookupHandlerMethod(108) | looking up handler for path: /ems/2.0/file/parser
DEBUG [http-nio-8080-exec-25] s.d.s.w.PropertySourcedRequestMappingHandlerMapping.getHandlerInternal(316) | Did not find handler method for [/ems/2.0/file/parser]
DEBUG [http-nio-8080-exec-25] o.h.e.t.s.AbstractTransactionImpl.begin(160) | begin
DEBUG [http-nio-8080-exec-25] o.h.e.j.i.LogicalConnectionImpl.obtainConnection(226) | Obtaining JDBC connection
DEBUG [http-nio-8080-exec-25] o.h.e.j.i.LogicalConnectionImpl.obtainConnection(232) | Obtained JDBC connection
DEBUG [http-nio-8080-exec-25] o.h.e.t.i.j.JdbcTransaction.doBegin(69) | initial autocommit status: true
DEBUG [http-nio-8080-exec-25] o.h.e.t.i.j.JdbcTransaction.doBegin(71) | disabling autocommit
DEBUG [http-nio-8080-exec-25] c.a.e.n.c.YangParser.parseModule(37) | Parse Yang module from file : /home/user/yang/iana-if-type.yang
DEBUG [http-nio-8080-exec-25] o.o.y.y.p.s.r.SourceSpecificContext.startPhase(206) | Source org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource@6e5d8661 started phase SOURCE_PRE_LINKAGE
DEBUG [http-nio-8080-exec-25] o.o.y.y.p.s.r.BuildGlobalContext.startPhase(287) | Global phase SOURCE_PRE_LINKAGE started
ERROR [http-nio-8080-exec-25] o.o.y.y.p.s.r.BuildGlobalContext.addSourceExceptions(326) | Failed to parse YANG from source SourceSpecificContext [source=org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource@6e5d8661, current=SOURCE_PRE_LINKAGE, finished=INIT]
org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: Yang model processing phase SOURCE_PRE_LINKAGE failed [at /home/user/yang/iana-if-type.yang:1:0]
    at org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.failModifiers(SourceSpecificContext.java:353) ~[yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.addSourceExceptions(BuildGlobalContext.java:316) [yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.completePhaseActions(BuildGlobalContext.java:410) [yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.executePhases(BuildGlobalContext.java:218) [yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.buildEffective(BuildGlobalContext.java:229) [yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    at org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor$BuildAction.buildEffective(CrossSourceStatementReactor.java:280) [yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    at com.example.common.YangParser.parseModule(YangParser.java:51) [classes/:na]
    at com.example.controllers.services.impl.FileServiceImpl.fileYangParser(FileServiceImpl.java:210) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) [spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at com.sun.proxy.$Proxy283.fileYangParser(Unknown Source) [na:na]
    at com.example.controllers.FileController.FileYangParser(FileController.java:133) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222) [spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) [spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) [spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814) [spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737) [spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) [spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) [spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) [spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) [spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) [servlet-api.jar:na]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) [servlet-api.jar:na]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.16]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.16]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.5.16]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.16]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.16]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at com.example.common.MDCFilter.doFilter(MDCFilter.java:38) [classes/:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at com.example.security.StatelessAuthenticationFilter.doFilter(StatelessAuthenticationFilter.java:39) [classes/:na]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177) [spring-security-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) [spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.16]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.16]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [catalina.jar:8.5.16]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.16]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) [catalina.jar:8.5.16]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.16]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) [catalina.jar:8.5.16]
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) [catalina.jar:8.5.16]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.16]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:8.5.16]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) [tomcat-coyote.jar:8.5.16]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.16]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-coyote.jar:8.5.16]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455) [tomcat-coyote.jar:8.5.16]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.16]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_144]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_144]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.16]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: Imported module [ietf-interfaces] was not found. [at /home/user/yang/iana-if-type.yang:5:2]
    at org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException.throwIf(InferenceException.java:47) ~[yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.ImportStatementDefinition$1.prerequisiteFailed(ImportStatementDefinition.java:118) ~[yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    at org.opendaylight.yangtools.yang.parser.stmt.reactor.ModifierImpl.failModifier(ModifierImpl.java:87) ~[yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    at org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.failModifiers(SourceSpecificContext.java:341) ~[yang-parser-impl-1.2.0-SNAPSHOT.jar:na]
    ... 92 common frames omitted
DEBUG [http-nio-8080-exec-25] o.h.e.t.s.AbstractTransactionImpl.rollback(205) | rolling back
DEBUG [http-nio-8080-exec-25] o.h.e.t.i.j.JdbcTransaction.doRollback(164) | rolled JDBC Connection
DEBUG [http-nio-8080-exec-25] o.h.e.t.i.j.JdbcTransaction.releaseManagedConnection(126) | re-enabling autocommit
DEBUG [http-nio-8080-exec-25] o.h.e.j.i.LogicalConnectionImpl.releaseConnection(246) | Releasing JDBC connection
DEBUG [http-nio-8080-exec-25] o.h.e.j.i.LogicalConnectionImpl.releaseConnection(264) | Released JDBC connection
ERROR [http-nio-8080-exec-25] c.a.e.n.c.FileController.handleAllException(140) | Parsing Yang module failed, error : Some of SOURCE_PRE_LINKAGE modifiers for statements were not resolved.
DEBUG [http-nio-8080-exec-25] c.a.e.n.c.MDCFilter.doFilter(45) | End filtering request with com.example.common.MDCFilter
DEBUG [http-nio-8080-exec-25] c.a.e.n.s.StatelessAuthenticationFilter.doFilter(41) | End filtering request with com.example.security.StatelessAuthenticationFilter

你能帮助我吗?

感谢。

2 个答案:

答案 0 :(得分:0)

我不是百分之百地追随你的行为,但我认为这个消息是关键:

Caused by: org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException: Imported module [ietf-interfaces] was not found. [at /home/user/yang/iana-if-type.yang:5:2]

所以你试图加载iana-if-type.yang,这对ietf-interfaces.yang有一个导入,它无法解决。但我不能100%确定你要做什么..

您是否已尝试在/ home / user / yang /中使用ietf-interfaces.yang?不确定是否有效 - 您可能必须告诉YANG解析器API何处/如何从中加载依赖项。在ODL中的RT期间,这通过来自CP的OSGi起作用。在ODL中的CLI mvn绑定生成期间,这是有效的,因为Maven插件查看项目CP以查找依赖的YANG模型。实际上,如果你look around the source code of the yang-maven-plugin如何找到依赖关系,你可以从中找出它吗?

HTH。否则,您也可以通过https://lists.opendaylight.org/mailman/listinfo/yangtools-dev获得更多有关此类内容的帮助。

答案 1 :(得分:0)

我正在查看yang-maven-plugin源代码,并想出了将所有文件添加到reactor的问题的解决方案。看一下示例代码。

CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();

        for (final URL url : files) {
            reactor.addSource(
                    YangStatementStreamSource.create(
                        YangTextSchemaSource.forFile(new File(url.getPath()))
                    )
            );
        }

        SchemaContext schemaContext = reactor.buildEffective();