views:

437

answers:

1

Hi,

I am very new to Spring and I have a simpleFormController with 2 methods. referenceData() with is called when the page loads and onSubmitAction() which is called on the submit of a form. I am getting a nullPointerExcpetion after all my onSubmitAction() code has completed and I suspect it has something to do with where the flow of control is going after the method is finished. I want referenceData() to be called after on submitAction() so that the page behaves the same way that it does when it loads first.

I have another requirement that may change what I think above. I want to pass back a success or error message based on the results of the onSubmitAction(). What is the best way to do this. Here are the relevant parts of my code:

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>

Thanks in advance for any advice....

Stack trace added

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)
A: 
java.lang.NullPointerException
    at com.ibm._jsp._communicationsAdmin._jspService(_communicationsAdmin.java:212)

Exceptions caused inside a JSP are hard to debug, especially if you didn't use scriptlets in a JSP at all. That would indicate a bug in the taglibrary used or a trivial configuration/flow error in the business logic which revealed this exception at the later stage.

To start, find the _communicationsAdmin.java file in the appserver's work directory and investigate line 212 for potential nullpointers and eventually trackback it to a potential configuration/flow error. If you have a hard time in debugging you could also paste the relevant (only the relevant yes) lines here so that we can maybe spot on for you.

BalusC
Thanks for the reply. I'm not really sure why the jsp being loaded though. I want the referenceData() method to be called before the request returns to the browser? I dont even know if that makes sense but I need to get a list of objects and return them in a map the same way as when the page loads initially
Caroline
Also, I dont know where to locate the .java version of the JSP? I'm doing a search of my hard drive but it doesn't seem to be finding anything
Caroline