2019-10-29 14:43
以下是报错信息:
[ERROR]-[Thread: XNIO-1 task-2]-[com.jfinal.core.ActionHandler.handle()]: com.xxkd.index.IndexController.g() : /g?page=1&limit=10
java.lang.IllegalArgumentException: Config already exists: getLedger
at com.jfinal.plugin.activerecord.DbKit.addConfig(DbKit.java:63)
at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:227)
at com.xxkd.index.IndexController.getLedger(IndexController.java:54)
at com.xxkd.index.IndexController.g(IndexController.java:28)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.jfinal.aop.Invocation.invoke(Invocation.java:97)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:89)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:89)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
======
加上时间变量进行信息打印
线程一:
dp start==>2019-10-29 14:30:10|null
ap start before==>2019-10-29 14:30:10|getLedger
ap start after==>2019-10-29 14:30:10|getLedger
....
ap stop before==>2019-10-29 14:30:10|getLedger
ap stop after==>2019-10-29 14:30:10|getLedger
dp stop==>2019-10-29 14:30:10|null
线程二:
dp start==>2019-10-29 14:30:10|null
ap start before==>2019-10-29 14:30:10|getLedger
ap start after==>2019-10-29 14:30:10|getLedger
....
ap stop before==>2019-10-29 14:30:10|getLedger
ap stop after==>2019-10-29 14:30:10|getLedger
dp stop==>2019-10-29 14:30:10|null
跟踪下,我想应该是多个线程同时访问产生的问题,以上复制了两个线程,发现时间是一样的。
所以,用了uuid后,发现是多线同一时间访问。
======
但是,activerecord stop后还是能获取到ap.getConfig().getName()名称
现在是不清楚该被调用的函数中的ActiveRecordPlugin和DruidPlugin是否被释放
2019-10-29 12:35
如果以 try(...) {} 方式来写,会报以下错误:
Incompatible types.
Required: java.lang.AutoCloseable
Found: com.jfinal.plugin.druid.DruidPlugin
Incompatible types.
Required: java.lang.AutoCloseable
Found: com.jfinal.plugin.activerecord.ActiveRecordPlugin
不支持close()。
代码改成以下:
DruidPlugin dp = null;
ActiveRecordPlugin ap = null;
try {
dp = new DruidPlugin(...);
ap = new ActiveRecordPlugin("getLedger", dp);
dp.start();
ap.start();
...
return
} finally {
ap.stop();
dp.stop();
ap = null; <-- 此处IDEA提示多余,但不这样写,总感觉没有释放掉
dp = null;
System.gc();
}
以上使用JMeter测试,10线程1秒时长,循环两次,测试时debug重启,还是会出现 Config already exists,将ActiveRecordPlugin的name改成uuid方式,则不再报错,但总感觉好像没有彻底释放,还有其他的什么方法没?
2019-10-08 15:02
Connected to the target VM, address: '127.0.0.1:2836', transport: 'socket'
Starting JFinal 4.5 -> http://0.0.0.0:8124
Info: jfinal-undertow 1.9, undertow 2.0.25.Final, jvm 1.8.0_20
Starting Complete in 2.2 seconds. Welcome To The JFinal World (^_^)
Exception in thread "HotSwapWatcher" java.lang.RuntimeException: java.io.IOException: 函数不正确。
还是提示这个
另外,WIN7是虚拟机