NutzCN Logo
分享 记录SysLog使用碰到的问题
发布于 1949天前 作者 Lsx1131188021 1910 次浏览 复制 上一个帖子 下一个帖子
标签:

环境:nutz 1.r.62 JDK1.8 Tomcat8.5
问题描述:使用Syslog记录系统日志(req.getParameter("xxx")),发现通过forward转发的请求,在SysLog中会报错,信息如下:

org.nutz.lang.InvokingException: Fail to invoke [org.apache.catalina.core.ApplicationHttpRequest].getParameter() by args:
 id
For the reason: Class org.nutz.lang.Invoking$DefaultInvoker can not access a member of class org.apache.catalina.core.ApplicationHttpRequest with modifiers "public"
	at org.nutz.lang.Invoking.invoke(Invoking.java:195)
	at org.nutz.lang.Mirror.invoke(Mirror.java:1100)
	at org.nutz.el.opt.object.AccessOpt.run(AccessOpt.java:71)
	at org.nutz.el.opt.object.MethodOpt.calculate(MethodOpt.java:48)
	at org.nutz.el.opt.object.InvokeMethodOpt.calculate(InvokeMethodOpt.java:22)
	at org.nutz.el.arithmetic.RPN.calculate(RPN.java:55)
	at org.nutz.el.arithmetic.RPN.calculate(RPN.java:38)
	at org.nutz.el.El.eval(El.java:33)
	at com.wonders.tiles.syslog.service.SysLogService.log(SysLogService.java:119)
	at com.wonders.tiles.syslog.aop.SysLogAopIntercepter.doLog(SysLogAopIntercepter.java:129)
	at com.wonders.tiles.syslog.aop.SysLogAopIntercepter.filter(SysLogAopIntercepter.java:119)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.wonders.tiles.statistics.at.QueryAt$$NUTZAOP.toQueryView(QueryAt.java:1)
	at com.wonders.tiles.statistics.at.QueryAt$FM$toQueryView$0dd2648f581d1483df6c4fbb1cedd6e2.invoke(QueryAt.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.wonders.tiles.processor.XssSqlFilterProcessor.process(XssSqlFilterProcessor.java:55)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.wonders.tiles.processor.LogTimeProcessor.process(LogTimeProcessor.java:38)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:467)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:392)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)
	at org.nutz.mvc.view.ForwardView.render(ForwardView.java:72)
	at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:55)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	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:478)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	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:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalAccessException: Class org.nutz.lang.Invoking$DefaultInvoker can not access a member of class org.apache.catalina.core.ApplicationHttpRequest with modifiers "public"
	at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
	at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(Unknown Source)
	at java.lang.reflect.AccessibleObject.checkAccess(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.nutz.lang.Invoking$DefaultInvoker.invoke(Invoking.java:47)
	at org.nutz.lang.Invoking.invoke(Invoking.java:192)
	... 78 more

经测试排查,浏览器直接访问这个URL时,请求被封装成org.apache.catalina.connector.RequestFacade,底层通过java反射机制调用了org.apache.catalina.connector.RequestFacade.getParameter();而使用forward的请求却被封装成org.apache.catalina.core.ApplicationRequest。造成上面报错的原因是org.apache.catalina.core.ApplicationRequest这个类没有用public修饰,通过反射调用org.apache.catalina.core.ApplicationRequest.getParameter()时就会报错。

临时解决方法:
直接修改tomcat的catalina.jar源码,加上public问题解决。

希望请教和讨论的内容:
1、http请求被封装成不同的Request,这个是Nutz做到的还是容器做到的?感觉不知道从哪里开始去摸索。
2、现在开发环境是直接修改的tomcat的jar,生产是使用的weblogic,所以直接修改catalina.jar肯定是个蠢办法,问题原因找到了,但是却没有找到最好的解决方式,请问大家有什么其他的解决方法么。

1 回复

版本问题??

添加回复
请先登陆
回到顶部