banq老师--jdon框架问题

12-06-28 mianwo602
jdon版本:JdonFramework_5.8.zip

问题:

当系统运行一定时间后出现如下错误:

2012-06-28 14:02:06,375 [http-80-exec-864] ERROR com.jdon.model.handler.HandlerObjectFactory - [JdonFramework]borrowHandlerObject error:java.util.NoSuchElementException

2012-06-28 14:02:06,375 [http-80-exec-864] ERROR com.jdon.model.ModelManagerImp - [JdonFramework]can't get the modelHandler for the formName b_news_form

2012-06-28 14:02:06,375 [http-80-exec-864] ERROR com.jdon.strutsutil.util.CreateViewPageUtil - [JdonFramework]please check your service 、 model or form, error is: java.lang.NullPointerException

2012-06-28 14:02:08,672 [http-80-exec-870] ERROR com.jdon.model.handler.HandlerObjectFactory - [JdonFramework]borrowHandlerObject error:java.util.NoSuchElementException

2012-06-28 14:02:08,672 [http-80-exec-870] ERROR com.jdon.model.ModelManagerImp - [JdonFramework]can't get the modelHandler for the formName b_news_form

2012-06-28 14:02:08,672 [http-80-exec-870] ERROR com.jdon.strutsutil.util.CreateViewPageUtil - [JdonFramework]please check your service 、 model or form, error is: java.lang.NullPointerException

2012-06-28 14:02:12,640 [http-80-exec-863] ERROR com.jdon.model.handler.HandlerObjectFactory - [JdonFramework]borrowHandlerObject error:java.util.NoSuchElementException

2012-06-28 14:02:12,640 [http-80-exec-863] ERROR com.jdon.model.ModelManagerImp - [JdonFramework]can't get the modelHandler for the formName b_news_form

2012-06-28 14:02:12,640 [http-80-exec-863] ERROR com.jdon.strutsutil.util.CreateViewPageUtil - [JdonFramework]please check your service 、 model or form, error is: java.lang.NullPointerException

2012-06-28 14:02:17,375 [http-80-exec-862] ERROR com.jdon.model.handler.HandlerObjectFactory - [JdonFramework]borrowHandlerObject error:java.util.NoSuchElementException

2012-06-28 14:02:17,375 [http-80-exec-862] ERROR com.jdon.model.ModelManagerImp - [JdonFramework]can't get the modelHandler for the formName b_ggl_form

2012-06-28 14:02:17,375 [http-80-exec-862] ERROR com.jdon.strutsutil.util.CreateViewPageUtil - [JdonFramework]please check your service 、 model or form, error is: java.lang.NullPointerException

错误代码分析:

2012-06-28 14:02:06,375 [http-80-exec-864] ERROR com.jdon.model.ModelManagerImp - [JdonFramework]can't get the modelHandler for the formName b_news_form

找不到b_news_form

导致ModelSaveAction中ModelSaveAction的ModelHandler modelHandler = modelManager.borrowtHandlerObject(formName);报错。

源码:

/**

* borrow a Handler instance from Modelhandler pool

*/

public ModelHandler borrowtHandlerObject(String formName) {

ModelHandler modelHandler = null;

try {

modelHandler = handlerObjectFactory.borrowHandlerObject(formName);

modelHandler.setModelMapping(modelFactory.getModelMapping(formName));

} catch (Exception ex) {

Debug.logError("[JdonFramework]can't get the modelHandler for the formName " + formName,

module);

returnHandlerObject(modelHandler);

}

return modelHandler;

}

导致后面的异常。

是不是存储formname的内存,被清空了。

banq老师蛮烦能不能帮忙解决下。

jdon这个版本已经从06年用到现在了,我们能够改的都改了,现在jdon的新版本我们暂时换了,客户太多,换的话怕出问题。

希望您这边能不能帮助解决下

    

banq
2012-06-28 18:37
又要翻N多年前代码了:

我对比看了一下,这里问题是原来5.8使用了handler pool,但是Pool被用光了造成这个问题,

将com.jdon.model.handler.HandlerObjectFactory的borrowHandlerObject和makeHandlerObject两个方法用下面代码替代即可。

public ModelHandler borrowHandlerObject(String formName) {
		ModelHandler modelHandler = null;
		try {
			modelHandler = makeHandlerObject(formName);
		} catch (Exception e) {
			Debug.logError("[JdonFramework]borrowHandlerObject error:" + e, module);
		}
		/**
		 * ModelHandler modelHandler = null; try { String poolKey =
		 * (modelHandlerClassBuilder.getModelMapping(formName)).getHandler();
		 * 
		 * LinkedList listFree = (LinkedList) handlerFreePool.get(poolKey); if
		 * ((listFree == null) || (listFree.isEmpty())) { // 如果空了,生产 listFree =
		 * makeHandlerObjects(formName); handlerFreePool.put(poolKey, listFree);
		 * } modelHandler = (ModelHandler) listFree.removeFirst();
		 * 
		 * // 加入已经用的池 LinkedList listUsed = (LinkedList)
		 * handlerUsedPool.get(poolKey); if (listUsed == null) { listUsed = new
		 * LinkedList(); handlerUsedPool.put(poolKey, listUsed); }
		 * listUsed.add(modelHandler);
		 * 
		 * Debug.logVerbose("[JdonFramework]--> borrow Modelhandler instance " +
		 * poolKey + listFree.size() + " for " + formName, module); } catch
		 * (Exception e) {
		 * Debug.logError("[JdonFramework]borrowHandlerObject error:" + e,
		 * module); }
		 **/
		return modelHandler;
	}

private synchronized ModelHandler makeHandlerObject(String formName) throws Exception {
		ModelHandler object = null;
		Class handlerClass = null;
		try {
			handlerClass = modelHandlerClassBuilder.getHandlerClasses(formName);
			if (handlerClass == null) {
				throw new Exception(" not found the handler in config xml formName=" + formName);
			}
			object = (ModelHandler) handlerClass.newInstance();
		} catch (Exception e) {
			Debug.logError("[JdonFramework]--> call Handler: " + handlerClass + " error:" + e, module);
			throw new Exception(e);
		}
		return object;
	}
<p>

主要是object = (ModelHandler) handlerClass.newInstance();这一句,直接使用JDK的创建对象,原来这里是调用POOL池(已经注释掉)

mianwo602
2012-06-29 09:47
问题已经按照您说的做了,本地测试运行没有问题。

客户机器上还待观察,谢谢banq老师

banq
2012-06-29 16:37
2012-06-29 09:47 "@mianwo602"的内容
客户机器上还待观察,谢谢banq老师 ...

你的并发访问量估计很大,Jdon框架这些问题是当初在并发千人压力测试下才发生的小概率事件,都在你的系统遇到了,不介意告知一下你访问量吧?

猜你喜欢