JSON解析器-java.lang.NoSuchFieldError:defaultReader [英] JSON Parser -java.lang.NoSuchFieldError: defaultReader

查看:783
本文介绍了JSON解析器-java.lang.NoSuchFieldError:defaultReader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JSON解析器提取值,并且正在使用以下jar json-path-2.1.0,调用在weblogic服务器上部署为webservice的用例时出现以下错误 我写了一个小的主程序来从json字符串中提取值,它工作正常,但是用例的服务器版本却出现了问题.我不确定我的耳朵中是否还有其他罐子会对这产生负面影响

I am using a JSON parser to extract the value and I am using the following jar json-path-2.1.0, and I am getting the following error when I invoke the use case deployed as webservice on weblogic server I wrote a small main program to extract the value from the json string and it works fine, but the server version of the use case is giving the issue. I am not sure if there are any other jars part of my ear can negatively impact this

SEVERE: defaultReader
java.lang.NoSuchFieldError: defaultReader
at com.jayway.jsonpath.spi.json.JsonSmartJsonProvider.<init>(JsonSmartJsonProvider.java:39)
at com.jayway.jsonpath.internal.DefaultsImpl.jsonProvider(DefaultsImpl.java:21)
at com.jayway.jsonpath.Configuration.defaultConfiguration(Configuration.java:174)
at com.jayway.jsonpath.internal.JsonContext.<init>(JsonContext.java:52)
at com.jayway.jsonpath.JsonPath.parse(JsonPath.java:596)

推荐答案

偶然发现了同样的问题.

Stumbled about the same problem.

它不起作用的原因不是JDK 8. 之所以遇到此问题,是因为weblogic 12.2.1.X捆绑了一些旧版本的json-smart.

The reason why it does not work is not the JDK 8. The reason why you encounter this issue, is the fact that weblogic 12.2.1.X is bundling some old version of json-smart.

在我的机器上,可以在这里找到: jar:文件:/C:/dev/WLS_12_2_1_2_0/oracle_common/modules/net.minidev.json-smart.jar!/net/minidev/json/JSONValue.class

On my machine this would be found here: jar:file:/C:/dev/WLS_12_2_1_2_0/oracle_common/modules/net.minidev.json-smart.jar!/net/minidev/json/JSONValue.class

现在,如果您使用的是依赖于json-smart的库(如json-path),那么默认情况下,容器将使用其内置模块之一加载所需的类.

Now if you are using a library like json-path that depends on json-smart, then by default the container will load the required class using one of its built-in modules.

您遇到的麻烦似乎是您的json路径所依赖的JSONValue类似乎具有此defaultReder字段. 这是正在爆炸的凝块的片段.

The blowup you have, seems to be that the JSONValue class that your json-path depends on seemed to have this defaultReder field. Here is a snipet of the clode that is blowing up.

 public JsonSmartJsonProvider() {
        this(JSONParser.MODE_PERMISSIVE, JSONValue.defaultReader.DEFAULT_ORDERED);
    }

那个

JSONValue.defaultReader

似乎在Weblogs较早的系统类加载器类上无效.

Seems not to be valid on weblogs older system class loader class.

您可以通过将如下所示的内容放入weblogic.xml部署描述符中来告诉容器使用您要包装的内容:

You can tell the container to use what you are packing by putting into your weblogic.xml deployment descriptor something like this:

<wls:prefer-application-packages>       
<wls:package-name>net.minidev.json.*</wls:package-name>                              
</wls:prefer-application-packages>

让weblogic吞下上述细粒度的指令时,我遇到了很多麻烦. 我发现自己强迫weblogic将所有进入web-inf文件夹的信息都记录下来,而不是这样做:

I am having quite a bit of trouble getting weblogic to swallow the fine-grained instruction above. I found myself to force weblogic to swallog all that goes into the web-inf folder instead doing:

 <wls:container-descriptor>
        <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>        
    </wls:container-descriptor>

我宁愿不像web-inf-class那样使用锤子,但是当我不粗粒度的时候,我正在与weblogic系统类加载器共舞...

I would have rather not be using a hammer like the web-inf-classes, but I am dancing with the weblogic system classloader when I do not go coarse grained...

致谢.

这篇关于JSON解析器-java.lang.NoSuchFieldError:defaultReader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆