gpt4 book ai didi

java - 使用yangtools解析yang模块失败

转载 作者:太空宇宙 更新时间:2023-11-04 11:05:09 25 4
gpt4 key购买 nike

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

我将这个依赖项添加到我的 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 的 Controller 中使用此函数来上传 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

你能帮我吗?

谢谢。

最佳答案

我不是 100% 明白你在做什么,但我认为这条信息很关键:

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 绑定(bind)生成期间,这是有效的,因为 Maven 插件会查看项目 CP 以查找依赖的 YANG 模型。事实上,如果你look around the source code of the yang-maven-plugin它如何找到依赖项,您可能可以从那里弄清楚?

HTH。否则,您也可以通过我们的https://lists.opendaylight.org/mailman/listinfo/yangtools-dev获得更多帮助。对于这样的事情。

关于java - 使用yangtools解析yang模块失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46547856/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com