net.sf.json.JSONException: java.lang.ClassCastException: com.ali.martini.biz.marketing.time.Parser$PeriodType cannot be cast to java.lang.String
at com.ali.martini.web.marketing.SendTimeDtoUtil$1.setProperty(SendTimeDtoUtil.java:210)
at net.sf.json.JSONObject.setProperty(JSONObject.java:1497)
at net.sf.json.JSONObject.toBean(JSONObject.java:387)
at com.ali.martini.common.JsonUtil.JSONStringToBean(JsonUtil.java:44)
at com.ali.martini.web.marketing.SendTimeDtoUtil.JSONStringToBean(SendTimeDtoUtil.java:216)
@Override publicvoid configure(WebAppContext context) throws Exception
{
//cannot configure if the context is already started if (context.isStarted())
{ if (Log.isDebugEnabled()){Log.debug("Cannot configure webapp "+context+" after it is started");} return;
}
Resource web_inf = context.getWebInf();
// Add WEB-INF classes and lib classpaths if (web_inf != null && web_inf.isDirectory() && context.getClassLoader() instanceof WebAppClassLoader)
{
// Look for classes directory
Resource classes= web_inf.addPath("classes/"); if (classes.exists())
((WebAppClassLoader)context.getClassLoader()).addClassPath(classes);
// Look for jars
Resource lib= web_inf.addPath("lib/"); if (lib.exists() || lib.isDirectory())
((WebAppClassLoader)context.getClassLoader()).addJars(lib);
}
...
}
/* ------------------------------------------------------------ */ /** Add elements to the class path for the context from the jar and zip files found
* in the specified resource.
* @param lib the resource that contains the jar and/or zip files.
*/ publicvoid addJars(Resource lib)
{ if (lib.exists() && lib.isDirectory())
{
String[] files=lib.list(); for (int f=0;files!=null && f<files.length;f++)
{ try
{
Resource fn=lib.addPath(files[f]);
String fnlc=fn.getName().toLowerCase(); if (!fn.isDirectory() && isFileSupported(fnlc))
{
String jar=fn.toString();
jar=StringUtil.replace(jar, ",", "%2C");
jar=StringUtil.replace(jar, ";", "%3B");
addClassPath(jar);
}
} catch (Exception ex)
{
Log.warn(Log.EXCEPTION,ex);
}
}
}
}
public String[] list()
{
String[] list =_file.list(); if (list==null) return null; for (int i=list.length;i-->0;)
{ if (new File(_file,list[i]).isDirectory() &&
!list[i].endsWith("/"))
list[i]+="/";
} return list;
}
实际使用的是java.io.file的list方法:
1
2
3
4
5
6
7
public String[] list() {
SecurityManager security = System.getSecurityManager(); if (security != null) {
security.checkRead(path);
} return fs.list(this);
}
最终调用的是 FileSystem的抽象方法
public abstract String[] list(File f);
在往下就是平台相关的代码了.
因为jdk源码查询不熟,所以写了一个简单代码,用外科的方式来考察: