1 Reply Latest reply on Mar 4, 2006 1:30 AM by tim.potter

    Spring mvc portlet examples not working in JBoss portal 2.2

    mackcom

      I hope someone here can help, I've also posted to the Spring forums looking for help as well...
      I've been having problems getting the spring-portlet-sample, books example to work in JBoss portal 2.2. I've tried with the older set of samples and with the new (as of today) set of samples that are refactored to work with Spring 2.0m1.

      My environment:
      JBoss AS 4.0.3SP1 with JBoss Portal 2.2
      Sun Java 1.5.0_05
      Spring 2.0m1
      Spring-portlet-sample (current version just downloaded today).

      This is what I'm experiencing:
      I can view all the pages in the books sample with out any problems. The issue occurs with I submit any of the forms (edit book details, add new book) in this example, or click on any of the ?update? icons (from book inventory, Increase count, descrease count, or delete book). When I submit any of these actions I get the following exception:

      15:10:50,149 ERROR [InvokeWindowActionCommand] An portlet exception occured in portlet /spring-portlet-sample.books
      java.lang.NullPointerException
       at org.jboss.portal.portlet.impl.ActionRequestImpl.getPortletMode(ActionRequestImpl.java:45)
       at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:448)
       at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:399)
       at org.jboss.portal.portlet.PortletContainer.invokeAction(PortletContainer.java:470)
       at org.jboss.portal.portlet.PortletContainer.dispatch(PortletContainer.java:411)
       at org.jboss.portal.server.app.ComponentInvocation.dispatch(ComponentInvocation.java:66)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:127)
       at org.jboss.portal.core.aspects.component.TransactionInterceptor.invoke(TransactionInterceptor.java:59)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:25)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:117)
       at org.jboss.portal.core.aspects.component.HeaderInterceptor.invoke(HeaderInterceptor.java:37)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:25)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:117)
       at org.jboss.portal.server.aspects.component.NavigationInterceptor.invoke(NavigationInterceptor.java:63)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:25)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:117)
       at org.jboss.portal.server.aspects.component.CacheInterceptor.invoke(CacheInterceptor.java:154)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:25)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:117)
       at org.jboss.portal.server.aspects.component.ModesInterceptor.invoke(ModesInterceptor.java:38)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:25)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:117)
       at org.jboss.portal.server.aspects.component.WindowStatesInterceptor.invoke(WindowStatesInterceptor.java:32)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:25)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:117)
       at org.jboss.portal.bridge.BridgeInterceptor.invoke(BridgeInterceptor.java:36)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:25)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:117)
       at org.jboss.portal.portlet.aspects.component.SessionPostDispatchInterceptor.invoke(SessionPostDispatchInterceptor.java:71)
       at org.jboss.portal.server.app.ComponentInterceptor.invoke(ComponentInterceptor.java:25)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:117)
       at org.jboss.portal.server.aspects.component.ContextDispatcherInterceptor$InvokeNextCommand.execute(ContextDispatcherInterceptor.java:116)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.portal.server.servlet.CommandServlet.doGet(CommandServlet.java:88)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.ApplicationDispatcher.invoke.java:117)
       at org.jboss.portal.server.aspects.server.ContentTypeInterceptor.invoke(ContentTypeInterceptor.java:55)
       at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:25)
       at org.jboss.portal.server.invocation.Invocation.invokeNext(Invocation.java:117)
      .... CUT so that this thread is < 10000 characters.
      


      I believe I have the deployed the portlet correctly because I don?t get any error on deployment. I have not changed anything in the sample code. I see in the readme for the samples that it is suggested that the web.xml may need to change (depending on the container), I didn?t change anything here because I could not find anything on the JBoss site that say I need to, and it has worked for me in the past without changes. Regarding the portlet.tld, the container copied it?s version of this into the WEB-INF/ dir of the deployment, so this should be ok.
      I did add a books-object.xml file to the WEB-INF/ dir of the deployment as a descriptor to tell JBoss where to display the portlet. I believe this is correct since it is display the pages/windows correctly. Here are the contents of that file:
      <?xml version="1.0" encoding="UTF-8"?>
      <deployments>
       <deployment>
       <if-exists>overwrite</if-exists>
       <parent-ref>default</parent-ref>
       <properties/>
       <page>
       <page-name>Books</page-name>
       <properties/>
       <window>
       <window-name>BooksPortletWindow</window-name>
       <instance-ref>BooksPortletInstance</instance-ref>
       <region>center</region>
       <height>0</height>
       </window>
       </page>
       </deployment>
       <deployment>
       <if-exists>overwrite</if-exists>
       <instance>
       <instance-name>BooksPortletInstance</instance-name>
       <component-ref>/spring-portlet-sample.books</component-ref>
       </instance>
       </deployment>
      </deployments>
      


      I?ve also created my own Spring portlet-mvc portlet and I?m having the same results. It is working great for rendering pages, but is not working at all when handling actions.

      Please help, any ideas you have will be appreciated. I?m very excited about getting Spring portlet MVC to work!


        • 1. Re: Spring mvc portlet examples not working in JBoss portal
          tim.potter

          I encountered a similar NPE error with the upload portlet and was able to get it working by explicitly setting the PortletMode for the Action URL used by the form:

          PortletURL uploadActionURL = renderResponse.createActionURL();
          uploadActionURL.setPortletMode(PortletMode.VIEW);
          
          ...
          
          <form id="uploadForm" action="<%=uploadActionURL.toString()%>" enctype="multipart/form-data" method="post">
          


          Doing this got me past the NPE and file uploads working as setup in the Spring MVC Portlet example.