File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Portals and Portlets and the fly likes Struts portlet on liferay giving Null pointer exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Struts portlet on liferay giving Null pointer exception" Watch "Struts portlet on liferay giving Null pointer exception" New topic
Author

Struts portlet on liferay giving Null pointer exception

Ram Charan
Greenhorn

Joined: Jun 07, 2008
Posts: 16
Hi All,
I have developed a struts portlet on liferay.

In Web.xml I am including
<servlet>
<servlet-name>ChangePassword</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortletServlet
</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>com.liferay.portlet.StrutsPortlet</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>ChangePassword</servlet-name>
<url-pattern>/ChangePassword/*</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>PortletActionServlet</servlet-name>
<servlet-
class>com.liferay.util.bridges.struts.LiferayPortletServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>PortletActionServlet</servlet-name>
<url-pattern>/portlet_action/*</url-pattern>
</servlet-mapping>


In portlet.xml i am including

<portlet>
<portlet-name>ChangePassword</portlet-name>
<display-name>Change Password</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>ViewPage</name>
<value>/portlet_action/changepassword/action</value>
</init-param>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-
bundle>
<expiration-cache>300</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
</portlet>


when tried to run I am getting the below exception

Uncaught exception thrown in one of the service methods of the servlet: ChangePassword. Exception thrown : java.lang.NullPointerException
at com.liferay.portlet.StrutsPortlet.include(StrutsPortlet.java:224)
at com.liferay.portlet.StrutsPortlet.doView(StrutsPortlet.java:195)
at com.liferay.portal.kernel.portlet.LiferayPortlet.doDispatch(LiferayPortlet.java:51)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:163)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:102)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)


My action class is extending com.liferay.portal.struts.PortletAction.

Let me know if I have to make any configuration changes. Thanks in Advance.

Regards,
Ram.
Yongming Duan
Greenhorn

Joined: May 08, 2006
Posts: 2
hi Ram,

There are two ways to impliment a struts portlet in liferay.

By the way, could you specify which version are you using?

You can see sample-struts-portlet or sample-struts-liferay-portlet.

try get more help and information on liferay forum
http://www.liferay.com/web/guest/community/forums

and liferay wiki http://wiki.liferay.com
mp mp
Greenhorn

Joined: Nov 27, 2008
Posts: 1
Hi Ram,

Even I was facing the same problem while developing a struts-portlet in Liferay until I could surprisingly find mPire-an Autogeneration tool for Liferay. I found this tool quite cool.

You have to just type in the commands to generate a full fledge struts-portlet in Liferay. No single line of code is required in order to generate a full fledge struts-portlet with all this features :

* CRUD operations on entities
* Filter / Search / Sorting on entities
* Pagination with configurable page size
* Lists: Drop-downs, Radio / Check boxes
* Relationship between various entities
* File Uploading & Data encryption options
* Completely AJAX based

You can save your time by using mPire-an Autogeneration tool for Liferay and get into action. You can download mPire from http://www.mpowerglobal.com/web/guest/mpiredownload

I am using this tool and its very helpful in generating portlets in Liferay, it can be used with almost all servers and database
[ November 27, 2008: Message edited by: mp mp ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"mp mp",
Please check your private messages.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts portlet on liferay giving Null pointer exception