Getting java.lang.NoSuchFieldError: VALUE in RamlValidationService

末鹿安然 提交于 2020-01-02 09:56:36

问题


I want to create a RAML validator that will get the RAML URLs resturn validation results. For that Im using raml-java-parser. As per its readme file I try to execute below line of code:

String sourceUrl = "http://api.apihub.com/onpositive/api/espn-raml-api/espn.raml";
List<ValidationResult> results = RamlValidationService.createDefault().validate(sourceUrl);

And get below error message:

java.lang.NoSuchFieldError: VALUE

Why I'm getting this error? Before that I got some class not found exceptions therefore I have applied below jar libraries manually.

> juniversalchardet_1.0.3_1.0.0.jar 
> raml_parser_0.8.11_1.0.0.jar
> rhino_1.7R4_1.0.0.jar 
> snakeyaml-1.16.jar
> jackson_databind_2.4.4_1.0.0.jar

I have tried below stuff as well. inputStream is the RAML content that I parsed through ByteArrayInputStream. But this is not a invalid RAML therefore I might doing something wrong.


回答1:


Never seen this error. I suspect you may still miss dependencies.

Indeed, the Java RAML parser has more dependencies than these few JARs you've manually added. And the dependencies you see in the pom are just the tip of the iceberg, there are tons of transitive dependencies as well.

So: use a proper dependency manager (like Maven) for your project. It will take care of bringing all the dependencies (direct and transitive) for you. Besides, unless this is a toy project, you will need a proper build tool anyway.



来源:https://stackoverflow.com/questions/32402777/getting-java-lang-nosuchfielderror-value-in-ramlvalidationservice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!