处理onSubmitAction后抛出异常

时间:2009-11-17 16:48:43

标签: java spring spring-mvc

我是Spring的新手,我有一个带有2个方法的simpleFormController。在页面加载时调用referenceData()with,在提交表单时调用onSubmitAction()。我的所有onSubmitAction()代码完成后我得到一个nullPointerExcpetion,我怀疑它与方法完成后控制流的位置有关。我希望在submitAction()之后调用referenceData(),以便页面的行为与首次加载时的行为方式相同。

我有另一项要求可能改变我的想法。我想根据onSubmitAction()的结果传回成功或错误消息。做这个的最好方式是什么。以下是我的代码的相关部分:

protected Map referenceData(PortletRequest arg0, Object arg1, Errors arg2) throws Exception 
    {
        Map<String, Object> model = new HashMap<String, Object>();

            List<Communication> allCommunications = dao.getAllCommunications();
            model.put("allCommunications", allCommunications);
            model.put("error", "");   //not sure how to get this data
            model.put("success", ""); //not sure how to get this data

        return model;
    }

protected void onSubmitAction(ActionRequest argRequest,
        ActionResponse argResponse, Object command, BindException errors)
        throws Exception
{
    Communication form = (Communication) command;

        dao.updateCommunication(form);
        //I want to set a success message here that can be read in the JSP

                                   

<bean id="communicationsValidator" class="com.admin.portlet.communication.CommunicationsValidator"/>

<bean id="communicationsController" class="com.admin.portlet.communication.CommunicationsAdminController">
    <property name="commandName" value="communications"/>
    <property name="commandClass" value="com.admin.portlet.communication.vo.Communication"/>
    <property name="formView" value="communications/communicationsAdmin"/>
    <property name="successView" value="communications/communicationsAdmin"/>
    <property name="validator"><ref bean="communicationsValidator"/></property>
    <property name="dao"><ref bean="communicationsDao"/></property>
</bean>

<bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
    <property name="order" value="1"/>
    <property name="portletModeMap">
        <map>
            <entry key="view"><ref bean="communicationsController"/></entry>
        </map>
    </property>
</bean>

提前感谢任何建议......

添加了堆栈跟踪

18/11/09 10:08:38:454 GMT] 0000002a ServletWrappe E   SRVE0068E: Uncaught exception thrown in one of the service methods of the servlet: /WEB-INF/jsp/communications/communicationsAdmin.jsp. Exception thrown : java.lang.NullPointerException
    at com.ibm._jsp._communicationsAdmin._jspService(_communicationsAdmin.java:212)
    at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
    at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
    at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
    at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:227)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:257)
    at org.springframework.web.servlet.ViewRendererServlet.renderView(ViewRendererServlet.java:111)
    at org.springframework.web.servlet.ViewRendererServlet.processRequest(ViewRendererServlet.java:84)
    at org.springframework.web.servlet.ViewRendererServlet.doGet(ViewRendererServlet.java:65)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
    at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
    at org.apache.jetspeed.dispatcher.JetspeedRequestDispatcher.include(JetspeedRequestDispatcher.java:73)
    at org.springframework.web.portlet.DispatcherPortlet.doRender(DispatcherPortlet.java:1140)
    at org.springframework.web.portlet.DispatcherPortlet.render(DispatcherPortlet.java:1094)
    at org.springframework.web.portlet.DispatcherPortlet.doRenderService(DispatcherPortlet.java:832)
    at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:483)
    at org.springframework.web.portlet.FrameworkPortlet.doDispatch(FrameworkPortlet.java:453)
    at javax.portlet.GenericPortlet.render(GenericPortlet.java:163)
    at org.apache.jetspeed.factory.JetspeedPortletInstance.render(JetspeedPortletInstance.java:103)
    at org.apache.jetspeed.container.JetspeedContainerServlet.doGet(JetspeedContainerServlet.java:277)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
    at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
    at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
    at org.apache.jetspeed.container.invoker.ServletPortletInvoker.invoke(ServletPortletInvoker.java:273)
    at org.apache.jetspeed.container.invoker.ServletPortletInvoker.render(ServletPortletInvoker.java:140)
    at org.apache.pluto.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:119)
    at org.apache.jetspeed.container.JetspeedPortletContainerWrapper.renderPortlet(JetspeedPortletContainerWrapper.java:121)
    at org.apache.jetspeed.aggregator.impl.RenderingJobImpl.execute(RenderingJobImpl.java:271)
    at org.apache.jetspeed.aggregator.impl.PortletRendererImpl.renderNow(PortletRendererImpl.java:228)
    at org.apache.jetspeed.aggregator.impl.PageAggregatorImpl.aggregateAndRender(PageAggregatorImpl.java:148)
    at org.apache.jetspeed.aggregator.impl.PageAggregatorImpl.aggregateAndRender(PageAggregatorImpl.java:144)
    at org.apache.jetspeed.aggregator.impl.PageAggregatorImpl.build(PageAggregatorImpl.java:78)
    at org.apache.jetspeed.aggregator.AggregatorValve.invoke(AggregatorValve.java:46)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.aggregator.HeaderAggregatorValve.invoke(HeaderAggregatorValve.java:53)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.decoration.DecorationValve.invoke(DecorationValve.java:144)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.resource.ResourceValveImpl.invoke(ResourceValveImpl.java:130)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.pipeline.valve.impl.ActionValveImpl.invoke(ActionValveImpl.java:207)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.container.ContainerValve.invoke(ContainerValve.java:109)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at com.fmr.fcpf.util.PageHistoryValve.invoke(PageHistoryValve.java:161)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.profiler.impl.ProfilerValveImpl.invoke(ProfilerValveImpl.java:248)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.security.impl.LoginValidationValveImpl.invoke(LoginValidationValveImpl.java:159)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.localization.impl.LocalizationValveImpl.invoke(LocalizationValveImpl.java:170)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.security.impl.AbstractSecurityValve$1.run(AbstractSecurityValve.java:138)
    at java.security.AccessController.doPrivileged(AccessController.java:215)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:645)
    at org.apache.jetspeed.security.JSSubject.doAsPrivileged(JSSubject.java:179)
    at org.apache.jetspeed.security.impl.AbstractSecurityValve.invoke(AbstractSecurityValve.java:132)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.container.url.impl.PortalURLValveImpl.invoke(PortalURLValveImpl.java:67)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.capabilities.impl.CapabilityValveImpl.invoke(CapabilityValveImpl.java:126)
    at org.apache.jetspeed.pipeline.JetspeedPipeline$Invocation.invokeNext(JetspeedPipeline.java:167)
    at org.apache.jetspeed.pipeline.JetspeedPipeline.invoke(JetspeedPipeline.java:146)
    at org.apache.jetspeed.engine.JetspeedEngine.service(JetspeedEngine.java:222)
    at org.apache.jetspeed.engine.JetspeedServlet.doGet(JetspeedServlet.java:242)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:930)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
    at com.fmr.fc.common.authentication.FCLoginFilter.doFilter(FCLoginFilter.java:269)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
    at com.fmr.fc.common.authentication.CommonPortalFilter.doFilter(CommonPortalFilter.java:194)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:761)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:673)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:498)
    at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3252)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:264)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
    at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1439)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:112)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)

1 个答案:

答案 0 :(得分:0)

java.lang.NullPointerException
    at com.ibm._jsp._communicationsAdmin._jspService(_communicationsAdmin.java:212)

JSP内部导致的异常很难调试,特别是如果您根本没有在JSP中使用scriptlet。这表明使用的taglibrary中存在错误,或者业务逻辑中存在一个简单的配置/流错误,这会在后期显示此异常。

首先,在appserver的工作目录中找到_communicationsAdmin.java文件并调查第212行以查找潜在的无效指针,并最终将其追溯到潜在的配置/流错误。如果您在调试中遇到困难,也可以在此处粘贴相关的(仅相关的是)行,以便我们可以为您找到。