Neither is working/generating content. In the case of the JBossPortal,
a portlet window is rendered with the appropriate title, but nothing in
it - not even an error, just a wide short box. Before I fixed some
other problems, I had seen what a portlet looks like when there is an
error, as well as when I had an incorrect URL and it was infinitely
nesting the whole portal within my portal. In the case of the test, it
returns an empty response. The portletunit framework
[http://m0smith.freeshell.org/portletunit/docs/index.php] is built on
top of httpunit's servletunit. So it does have mocked versions of the
portlet request and response objects.
I did read both of your blog entries on using jetty:run and incorporated
the part 2 approach into my build. Unfortunately, I may have run into
the Spring or jar issues you mentioned. Did you see these exceptions in
your journey to assemble your test harness framework? I am using Spring
created Actions, which did not exist in your examples. Would that cause
a problem? Thank you very much for the help.
01:19:31,703 DEBUG
[org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver]
Ignoring namespace handler
[org.springframework.scripting.config.LangNamespaceHandler]: handler
class not found
java.lang.ClassNotFoundException:
org.springframework.scripting.config.LangNamespaceHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
01:19:31,718 DEBUG
[org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver]
Ignoring namespace handler
[org.springframework.ejb.config.JeeNamespaceHandler]: handler class not
found
java.lang.ClassNotFoundException:
org.springframework.ejb.config.JeeNamespaceHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at
org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
01:19:31,718 DEBUG
[org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver]
Ignoring namespace handler [o
rg.springframework.aop.config.AopNamespaceHandler]: handler class not found
java.lang.ClassNotFoundException:
org.springframework.aop.config.AopNamespaceHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
01:19:32,171 INFO [org.apache.pluto.driver.PortalStartupListener]
Starting up Pluto Portal Driver. . .
2007-08-16 01:19:32.883::WARN: Failed startup of context
[EMAIL PROTECTED]/gridportlet,C:\Multideck\GTS\StrutsPortletExample\src\main\webapp}
java.lang.ClassCastException:
org.springframework.web.context.support.XmlWebApplicationContext
at
org.apache.pluto.driver.PortalStartupListener.contextInitialized(PortalStartupListener.java:98)
at
org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:530)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
at
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1219)
at
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
Nils-Helge Garli wrote:
So it doesn't work in neither JBoss nor your tests? Or is it just your
test that is not working?
Since executeRegularServletResult is executed, the only two reasons are:
- The portletrequest and portletresponse objects are not available,
which means you're running outside the container.
- The urls used to access the portlet is incorrect.
I'm not familiar with portletunit, but have you set up the request and
response objects correctly? Maybe you have an example unit test you
can show us?
BTW: If you want to test your portlets visually without starting a
heavy-weight container, take a look at my two blog articles regarding
testing portlets with pluto and maven:
http://portletwork.blogspot.com/2007/07/mvnjetty-and-portlets.html
http://portletwork.blogspot.com/2007/08/maven-jetty-plugin-and-jsr168-portlets.html
On 8/15/07, Frederick N. Brier <[EMAIL PROTECTED]> wrote:
In my portletunit test, I am using a url of
"view/viewMyPortlet.action". In JBossPortal, I create a Portlet
Instance from the Portlet Definition and then under the Portlet Objects
tab assign it to a region in the page layout. Is there somewhere I
would specify a URL? And what would it be? What URL would you suggest
I specify in portletunit? That would be helpful as I am trying to use
that as a test harness and avoid launching a container. Thank you!!
Fred
Nils-Helge Garli wrote:
Are you creating the urls correctly using the s:url tag? Do you have
an example JSP? How do you invoke your portlet application? Remember
that you can't access the portlet using regular urls, they all have to
go through the portlet container.
Nils-H
On 8/15/07, Frederick N. Brier <[EMAIL PROTECTED]> wrote:
I am pretty sure this is a configuration issue, probably in struts.xml.
I am trying to create a JSR168 compliant portlet. I have been working
with the portletunit code to get it to execute in a unit test, as well
as running it with JBossPortal. The behavior is the same, so I am
hoping it is not an issue of the test harness introducing an issue. I
debug/traced the execution. The Action is correctly constructed using
the SpringFactory along with all properties. It is invoked and executes
without error. It gets to DefaultActionInvocation having created a
PortletResult, and calls result.execute(this). The lastFinalLocation is
set to the location of the jsp specified in the struts.xml.
PortletResult.doExecute() calls executeRegularServletResult().
Should I have been in render mode at this point and had
executeRenderResult called instead? I have seen a number of posting
saying "best practice" is to redirect to another action executing in
render phase that then specifies the jsp as the result. Mine ends up
calling PreparatorServlet.service and sets up the servlet request
parameters into the ActionContext, and then ends, having never called
the jsp. I also am not seeing where the Jsr168Dispatcher is ever
invoked. It does not show up in the stack as I execute. I do not know
if that is an issue.
I have tried a number of combinations of XML including trying to
redirect to a "renderDirect.action" which then redirects to the .jsp.
Problem is that I have found no examples of using this action, and I
have not stumbled on the answer. I have tried setting the result type
to redirect... no joy. I am using Struts 2.0.9. If anyone could take a
peek at my struts.xml and tell me what I am doing wrong, I would be
eternally grateful. I do not understand how my code differs from the
HelloWorld portlet examples that I started with. Thank you.
Fred
--------------------------struts.xml-------------------------------
<?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="basePortlet" extends="struts-portlet-default">
<interceptors>
<interceptor-stack name="portletStack">
<interceptor-ref name="basicStack"/>
<interceptor-ref name="portlet-preferences" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="portletStack"/>
</package>
<package name="view" extends="basePortlet" namespace="/view">
<action name="index" class="viewMyPortlet">
<result name="success">/WEB-INF/view/MyPortlet.jsp</result>
</action>
<action name="viewMyPortlet" class="viewMyPortlet">
<result name="success">/WEB-INF/view/MyPortlet.jsp</result>
</action>
<action name="viewMyPortletSubcomponent1" class="viewMyPortlet">
<result
name="success">/WEB-INF/view/MyPortletSubcomponent1.jsp</result>
</action>
</package>
<package name="edit" extends="basePortlet" namespace="/edit">
<action name="index" class="com.opensymphony.xwork2.ActionSupport">
<result name="success">/WEB-INF/edit/index.jsp</result>
</action>
</package>
<package name="help" extends="basePortlet" namespace="/help">
<action name="index" class="com.opensymphony.xwork2.ActionSupport">
<result name="success">/WEB-INF/help/index.jsp</result>
</action>
</package>
</struts>
--------------------------applicationContext.xml-------------------
...
<bean id="viewMyPortlet" class="com.mycompany.MyPortletAction"
scope="prototype" autowire="byName">
...
</bean>
...
--------------------------portlet.xml--------------------------------
<portlet-app version="1.0"
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.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" id="struts-portlet">
<portlet id="MySamplePortlet">
<description>A Sample Portlet</description>
<portlet-name>MySamplePortlet</portlet-name>
<display-name>Sample Portlet</display-name>
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
<init-param>
<!-- The view mode namespace. Maps to a namespace in the xwork
config file -->
<name>viewNamespace</name>
<value>/view</value>
</init-param>
<init-param>
<!-- The default action to invoke in view mode -->
<name>defaultViewAction</name>
<value>index</value>
</init-param>
<init-param>
<!-- The view mode namespace. Maps to a namespace in the xwork
config file -->
<name>editNamespace</name>
<value>/edit</value>
</init-param>
<init-param>
<!-- The default action to invoke in view mode -->
<name>defaultEditAction</name>
<value>index</value>
</init-param>
<init-param>
<!-- The view mode namespace. Maps to a namespace in the xwork
config file -->
<name>helpNamespace</name>
<value>/help</value>
</init-param>
<init-param>
<!-- The default action to invoke in view mode -->
<name>defaultHelpAction</name>
<value>index</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>edit</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>Sample Portlet</title>
<short-title>Sample View Portlet</short-title>
<keywords>Sample View</keywords>
</portlet-info>
</portlet>
</portlet-app>
--------------------------web.xml--------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!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 id="MyPortletPortlet">
<!-- Uncomment/comment this if you need/don't need Spring support -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<filter id="filterdispatcher">
<filter-name>action2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>action2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.apache.struts2.portlet.context.ServletContextHolderListener
</listener-class>
</listener>
<servlet id="preparator">
<servlet-name>preparator</servlet-name>
<servlet-class>
org.apache.struts2.portlet.context.PreparatorServlet
</servlet-class>
</servlet>
<servlet id="dwr">
<servlet-name>dwr</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>preparator</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>dwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
</web-app>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]