English 中文(简体)
Java-JSON对象和ListOrderedMap问题
原标题:Java - JSON Object and ListOrderedMap problem

我试图在代码中使用JSON-lib-api将java对象转换为JSONObject。

我已经将下面链接中指定版本的所有依赖项添加到我的j2ee web模块依赖项中

http://json-lib.sourceforge.net/

然而,每当我调用JSONObject.fromObject()方法时,我都会得到NoSuchMethodError。

我还应该指出,完全相同的代码和依赖项在我的tomcat服务器上工作,但在我的websphereapplicationserver上不工作。有人知道我做错了什么吗?

下面的部分堆栈跟踪:

 E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[SpringMVCServlet]: java.lang.NoSuchMethodError: org/apache/commons/collections/map/ListOrderedMap.<init>()V
    at net.sf.json.JSONObject.<init>(JSONObject.java:1450)
    at net.sf.json.util.CycleDetectionStrategy.<clinit>(CycleDetectionStrategy.java:37)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
    at net.sf.json.JsonConfig.<clinit>(JsonConfig.java:65)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
    at net.sf.json.JSONObject.fromObject(JSONObject.java:134)
最佳回答

确保WEB-INF/lib中有正确版本的commons collections jar,然后在WebSphere管理控制台中设置“Classes loaded with application class loader first”选项,如此处

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签