We have been using the Pluto 1.1.6 Portlet container
(http://portals.apache.org/pluto/) to test our JSR-168 portlets. Our
team needs help learning the correct way to setup a Struts 2 portlet to
run within the Pluto 1.1.6 portlet container. We've studied the Struts
2 example portlet tutorial
(http://struts.apache.org/2.0.11.1/docs/struts-2-portlet-tutorial.html )
in the Struts 2 documentation. However, that portlet is deployed using
maven, jetty, and Pluto; which unfortunately is not our development
environment.
We recently have begun using Struts 2 to create the Portlets. However,
we cannot get the Struts 2 portlets to run correctly in the Pluto
portlet container. When Pluto tries to render the Struts 2 portlet we
get the following error:
INFO: Registering 1 portlets for context /StrutsExample
Dec 5, 2008 8:36:36 AM org.apache.pluto.core.PortletContextManager
getPortletConfig
INFO: Unable to locate portlet config
[applicationId=/StrutsExample]/[null].
Dec 5, 2008 8:36:36 AM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.NullPointerException
at
org.apache.pluto.core.PortletServlet.init(PortletServlet.java:106)
Our non-Struts 2 portlets that we've built and deployed in the Pluto
container work fine.
We have developed a very simple Struts 2 portlet as a test. Here is its
struts.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-portlet-default.xml"/>
<package name="view" extends="struts-portlet-default"
namespace="/view">
<action name="index" class="DefaultAction">
<result name="success">/jsp/index.jsp</result>
</action>
</package>
</struts>
Here is its portlet.xml file:
<?xml version='1.0' encoding='UTF-8' ?>
<portlet-app
xmlns='http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://java.sun.com/xml/ns/portlet/portlet-app_1_0.x
sd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd'
version='1.0'>
<portlet id="StrutsExamplePortlet">
<description xml:lang="EN">Simple hello world portlet using
Struts 2</description>
<portlet-name>StrutsExamplePortlet</portlet-name>
<display-name xml:lang="EN">StrutsExample</display-name>
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</p
ortlet-class>
<!-- The namespace for the actions configured for view mode
-->
<init-param>
<name>viewNamespace</name>
<value>/view</value>
</init-param>
<!-- The default action to invoke in view mode. -->
<init-param>
<name>defaultViewAction</name>
<value>index</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>StrutsExample</title>
</portlet-info>
</portlet>
</portlet-app>
Here is the project's web.xml:
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>StrutsExample</display-name>
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-cla
ss>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>StrutsExample</servlet-name>
<servlet-class>org.apache.pluto.core.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</par
am-value>
</init-param>
<init-param>
<param-name>portlet-guid</param-name>
<param-value>
StrutsExample.StrutsExamplePortlet
</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>StrutsExample</servlet-name>
<url-pattern>/PlutoInvoker/StrutsExample/*</url-pattern>
</servlet-mapping>
</web-app>
Here is the relevant part of the pluto-portal-driver-config.xml file
that we added to have the Struts 2 portlet added to a page in the Pluto
container:
<page name="Struts Portlet Example"
uri="/WEB-INF/themes/pluto-default-theme.jsp">
<portlet context="/StrutsExample" name="StrutsExample"/>
</page>
I think the problem is with the code we are adding to the
pluto-portal-driver-config.xml file. Though the above syntax works for
standard Portlets, it's not working for a Struts 2 portlet.
I'd welcome any feedback from developers who have built Portlets using
Struts 2 and then successfully deployed the portlet to the Pluto
container.
Bruce