启动Tomcat后访问 http://192.168.199.10:8080/jpress-web-newest 网页,查看日志有报错
问题原因:Java的内存溢出
故障现象为:
cat /apps/links/tomcat/logs/catalina.out
2018-11-05 16:08:55
[ERROR]-[Thread: http-nio--exec-]-[io.jpress.admin.controller._AttachmentController.processImage()]: processThumbnail error
java.lang.IllegalArgumentException: sourceRegion.x < 0!
at javax.imageio.IIOParam.setSourceRegion(IIOParam.java:188)
at io.jpress.utils.ImageUtils.readBuffereImage(ImageUtils.java:112)
at io.jpress.utils.ImageUtils.scale(ImageUtils.java:83)
at io.jpress.utils.ImageUtils.scale(ImageUtils.java:61)
at io.jpress.admin.controller._AttachmentController.processThumbnail(_AttachmentController.java:166)
at io.jpress.admin.controller._AttachmentController.processImage(_AttachmentController.java:149)
at io.jpress.admin.controller._AttachmentController.doUpload(_AttachmentController.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
at io.jpress.core.interceptor.ActionCacheClearInterceptor.intercept(ActionCacheClearInterceptor.java:27)
at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
at io.jpress.core.interceptor.HookInterceptor.intercept(HookInterceptor.java:31)
at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
at io.jpress.interceptor.AdminInterceptor.intercept(AdminInterceptor.java:52)
at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
at io.jpress.interceptor.GlobelInterceptor.intercept(GlobelInterceptor.java:33)
at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
at io.jpress.core.interceptor.JI18nInterceptor.intercept(JI18nInterceptor.java:48)
at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:82)
at io.jpress.core.MyDruidStatViewHandler.handle(MyDruidStatViewHandler.java:43)
at io.jpress.core.cache.ActionCacheHandler.handle(ActionCacheHandler.java:40)
at io.jpress.core.JHandler.handle(JHandler.java:81)
at io.jpress.core.cache.ActionCacheHandler.handle(ActionCacheHandler.java:40)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
▽ at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
解决方案一:
设置MyEclipse中Tomcat使用的Jdk的VM arguments:
-Xms512m -Xmx1024m -XX:MaxNewSize=512m -XX:MaxPermSize=512m
如图:
解决方法二:
手动设置MaxPermSize大小
修改TOMCAT_HOME/bin/catalina.bat(Linux下为catalina.sh),在“echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行:
set JAVA_OPTS=%JAVA_OPTS% -server -XX:PermSize=128M -XX:MaxPermSize=512m
catalina.sh下为:
JAVA_OPTS="$JAVA_OPTS -server -XX:PermSize=128M -XX:MaxPermSize=512m"