Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts portlet on liferay giving Null pointer exception

 
Ram Charan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic