struts-portlet-plugin开发portlet时报错

异常:Exception occurred during processing request: null

08:36:23,796 ERROR [struts2.dispatcher.Dispatcher] Exception occurred during processing request: null
java.lang.NullPointerException
at org.apache.struts2.portlet.interceptor.PortletStateInterceptor.intercept(PortletStateInterceptor.java:49)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
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:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)

 

 这个是使用struts-portel-plugin开发portlet时遇到的异常,主要原因是如下处的phase为空造成的。

@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		PortletPhase phase = (PortletPhase) invocation.getInvocationContext().get(PortletConstants.PHASE);
		if (phase.isRender()) {
			restoreStack(invocation);
			return invocation.invoke();
		} else if (phase.isAction()) {
			try {
				return invocation.invoke();
			} finally {
				saveStack(invocation);
			}
		} else {
			return invocation.invoke();
		}
	}

 解决方法:用struts-portlet-plugin开发portlet时不能在web.xml中添加如下的struts过滤器,去掉即可了。

<!-- 	<filter> -->
<!-- 		<filter-name>struts2</filter-name> -->
<!-- 		<filter-class> -->
<!-- 			org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter -->
<!-- 		</filter-class> -->
<!-- 	</filter> -->

<!-- 	<filter-mapping> -->
<!-- 		<filter-name>struts2</filter-name> -->
<!-- 		<url-pattern>/*</url-pattern> -->
<!-- 	</filter-mapping> -->

 

你可能感兴趣的:(exception,null,processing,occurred,request:,during)