Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3164

Using Struts 2.1.6 Portlet Plugin Causes NullPointerException When Executing A Normal Struts 2 Action

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.6
    • 2.1.8
    • Plugin - Portlet
    • None
    • Windows XP, JDK 6

    Description

      Created a Struts 2 web/portlet application with a pom.xml having a dependency on struts2-core-2.0.11.2.jar. Works both as a normal web application and as a portlet application.

      Changed the dependencies to be struts2-core-2.1.6.jar and struts2-portlet-plugin-2.1.6.jar. Running the application as a web application in Tomcat 6 or Jetty results in a org.apache.jasper.JasperException: java.lang.NullPointerException whenever a Struts 2 action is called.

      Removed the dependency on struts2-portlet-plugin-2.1.6.jar and the application runs fine as a normal Struts 2 web application.

      You can download an archived Eclipse dynamic web project that uses maven here:

      http://www.brucephillips.name/struts/struts2portletexample.zip

      1. Unzip the project
      2. In a command window navigate to where you unzipped the project
      3. In the root folder for the project run mvn clean
      4. Then run mvn jetty:run
      5. Open your browser and go to http://localhost:8080/StrutsPortletExample/index.html
      6. click on the link for add new employee
      7. You'll get a NullPointerException
      8. Close Jetty by using Control C
      9. In the pom.xml file for the project comment out the dependency on Struts 2.1.6 Porlet Plugin
      10. In command window redo mvn clean and then mvn jetty:run
      11. Open your browser and go to http://localhost:8080/StrutsPortletExample/index.html
      12. click on the link for add new employee and the Struts 2 action will execute successfully and you'll get the add employee page

      In Struts 2.0.11 we were able to use both Struts 2 actions and a Struts 2 portlet in the same web application. Trying to use the new Struts 2.1.6 Portlet Plugin causes an exception when user clicks on a normal struts 2 action link.

      Here is the first part of the Exception stack trace as reported by Struts 2:

      Struts Problem Report

      Struts has detected an unhandled exception:

      1. Messages: java.lang.NullPointerException
        File: org/apache/struts2/components/UIBean.java
        Line number: 792
        Stacktraces
        org.apache.jasper.JasperException: java.lang.NullPointerException

      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:418)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
      org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
      org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
      org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
      org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:334)
      org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
      org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:154)

      Attachments

        1. StrutsExample.zip
          15 kB
          Bruce Phillips
        2. Struts2PortletExample.zip
          45 kB
          Bruce Phillips

        Activity

          People

            nilsga Nils-Helge Garli
            phillips1021 Bruce Phillips
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: