淘宝网表现层设计分析
前几天突然发现淘宝网访问非常慢而且出错(出现异常),猜测是淘宝网在发布新版本时出现错误或是某个服务器出现异常。但淘宝网的工程师在输出错误时生成了客户端注释掉的Java异常信息(包含在<!--和-->之间),虽然在画面上是看不到的,但查看源代码就可以清楚的看到这个Java出错信息。
淘宝网采用阿里巴巴自己开发的一个MVC框架,动态网页(jhtml页面)的通用入是口WebxControllerServlet,最终调用/执行模版是在TemplateModule的子类中完成的,然后在Module执行完成后跳转到一个视图(JSP文件),在Servlet和Module中是通过Valve的职责链处理。
图1 淘宝网部分类图
一个Web请求的基本处理流程是:
客户端发出Web请求
WebxControllerServlet
PerformScreenTemplateValve
TemplateModule
附(本文基于下面的异常分析):
Exception: com.alibaba.webx.WebxException: Failed to execute screen: home.MyTaobao (template:
screen/home/myTaobao.vm)
at com.alibaba.webx.WebxControllerServlet.handleRequest(WebxControllerServlet.java:111)
at com.alibaba.webx.controller.AbstractWebxControllerServlet.doGet(AbstractWebxControllerServlet.java:113)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.alibaba.webx.filter.rundata.RunDataFilter.doFilter(RunDataFilter.java:48)
at com.alibaba.webx.filter.AbstractFilter.doFilter(AbstractFilter.java:150)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.taobao.common.webx.filter.RemoteAddrFilter.doFilter(RemoteAddrFilter.java:16)
at com.alibaba.webx.filter.AbstractFilter.doFilter(AbstractFilter.java:150)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.alibaba.webx.filter.timer.TimerFilter.doFilter(TimerFilter.java:93)
at com.alibaba.webx.filter.AbstractFilter.doFilter(AbstractFilter.java:150)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:419)
at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:378)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
at java.lang.Thread.run(Thread.java:595)
Caused by: com.alibaba.service.pipeline.PipelineException: Failed to execute screen: home.MyTaobao (template:
screen/home/myTaobao.vm)
at com.alibaba.turbine.pipeline.PerformScreenTemplateValve.performScreenModule
(PerformScreenTemplateValve.java:112)
at com.alibaba.turbine.pipeline.PerformScreenTemplateValve.invoke(PerformScreenTemplateValve.java:48)
at com.alibaba.turbine.pipeline.AbstractValve.invoke(AbstractValve.java:33)
at com.alibaba.service.pipeline.DefaultPipeline.invokeNext(DefaultPipeline.java:224)
at com.alibaba.service.pipeline.DefaultPipeline.invoke(DefaultPipeline.java:187)
at com.alibaba.turbine.pipeline.ChooseValve$Condition.invokeSubPipeline(ChooseValve.java:82)
at com.alibaba.turbine.pipeline.ChooseValve.invoke(ChooseValve.java:57)
at com.alibaba.turbine.pipeline.AbstractValve.invoke(AbstractValve.java:33)
at com.alibaba.service.pipeline.DefaultPipeline.invokeNext(DefaultPipeline.java:224)
at com.alibaba.service.pipeline.DefaultPipeline.invoke(DefaultPipeline.java:187)
at com.alibaba.service.pipeline.TryCatchFinallyValve.invokeTryPipeline(TryCatchFinallyValve.java:114)
at com.alibaba.webx.WebxControllerServlet.handleRequest(WebxControllerServlet.java:108)
... 33 more
Caused by: com.alibaba.webx.WebxException: [MyTaobao] Response is null or failed
at com.taobao.web.mytaobao.module.screen.home.MyTaobao.execute(MyTaobao.java:104)
at com.alibaba.turbine.module.TemplateModule.execute(TemplateModule.java:38)
at com.alibaba.turbine.pipeline.PerformScreenTemplateValve.performScreenModule
(PerformScreenTemplateValve.java:108)
... 44 more
以上是 淘宝网表现层设计分析 的全部内容, 来源链接: utcz.com/p/205542.html