JSONException in hicc.log file
------------------------------
Key: CHUKWA-543
URL: https://issues.apache.org/jira/browse/CHUKWA-543
Project: Chukwa
Issue Type: Bug
Components: User Interface
Affects Versions: 0.4.0
Reporter: Eric Yang
Assignee: Eric Yang
Quote from mailing list:
Hi all,
We deployed chukwa on a 5 nodescluster where hadoop's version is
hadoop 0.20.2 and chukwa's is 0.4.0. After some logs of NameNode were
successfully collectected and processed by chukwa, we started hicc
server. The hicc produced files listed below on HDFS,
# bin/hadoop dfs -lsr /chukwa/hicc/views/
drwxr-xr-x - root supergroup 0 2010-11-04 13:01
/chukwa/hicc/views/public
-rw-r--r-- 2 root supergroup 22177 2010-11-04 13:01
/chukwa/hicc/views/public/default.view
-rw-r--r-- 2 root supergroup 236 2010-11-04 13:01
/chukwa/hicc/views/public/newview.tpl
-rw-r--r-- 2 root supergroup 46 2010-11-04 13:01
/chukwa/hicc/views/public/view.permission
-rw-r--r-- 2 root supergroup 103 2010-11-04 13:01
/chukwa/hicc/views/public/workspace_view_list.cache
drwxr-xr-x - root supergroup 0 2010-11-04 13:01
/chukwa/hicc/views/users
We digged into the hicc.log and found that it encountered some
exceptions about JSON.
2010-11-04 14:00:16,954 ERROR btpool0-3 ViewBean -
org.json.JSONException: JSONObject["owner"] not found.
at org.json.JSONObject.get(JSONObject.java:283)
at org.json.JSONObject.getString(JSONObject.java:409)
at org.apache.hadoop.chukwa.rest.bean.ViewBean.<init>(ViewBean.java:62)
at org.apache.hadoop.chukwa.datastore.ViewStore.list(ViewStore.java:217)
at
org.apache.hadoop.chukwa.rest.resource.ViewResource.getUserViewList(ViewResource.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:156)
at
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
at
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:166)
at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:114)
at
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:74)
at
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:114)
at
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:66)
at
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:658)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:616)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:607)
at
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:309)
/pathList
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
After further analysis, we found the problem is caused by at lines in
ViewStore.list()
String[] pathList = new String[2];
pathList[0]=viewPath.toString();
pathList[1]=publicViewPath;
JSONArray list = new JSONArray();
for(String path : pathList) {
Path viewFile = new Path(path);
try {
FileSystem fs = FileSystem.get(config);
FileStatus[] fstatus = fs.listStatus(viewFile);
if(fstatus!=null) {
for(int i=0;i<fstatus.length;i++) {
long size = fstatus[i].getLen();
FSDataInputStream viewStream = fs.open(fstatus[i].getPath());
byte[] buffer = new byte[(int)size];
viewStream.readFully(buffer);
viewStream.close();
try {
ViewBean view = new ViewBean(new JSONObject(new String(buffer)));
JSONObject json = new JSONObject();
json.put("name", view.getName());
json.put("type", view.getPermissionType());
json.put("owner", view.getOwner());
if(uid.intern()==view.getOwner().intern()) {
json.put("editable","true");
} else {
json.put("editable","false");
}
list.put(json);
} catch (Exception e) {
log.error(ExceptionUtil.getStackTrace(e));
}
}
}
} catch (IOException ex) {
...
}
}
All files of /chukwa/hicc/views/public/ would be read and then parsed
into json objects. After that, those json objects were passed to
ViewBean's constructor which will run
json.getString("owner"). But there is only one file(default.view) 's
json has this key. So the exception throwed.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.