Problem with deploying simple Spring MVC Portlet to Liferay 5.2.3
- by Johannes Hipp
Hello,
I try to deploy a simple spring portlet in ext (I can't use Plugins SDK...) on Liferay 5.2.3
My portlet:
ext-impl/src:
package: com.ext.portlet.springmvc
HelloWorldController.java
[code]
package com.ext.portlet.springmvc;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class HelloWorldController implements Controller {
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String aMessage = "Hello World MVC!";
ModelAndView modelAndView = new ModelAndView("hello_world");
modelAndView.addObject("message", aMessage);
return modelAndView;
}
}
[/code]
ext-lib:
- jstr.jar
- spring-webmvc.jar
- spring-webmvc-portlet.jar
- spring.jar
- standard.jar
ext-web/docroot/html/portlet/ext/springmvc/hello_world.jsp
[code]
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<p>This is my message: ${message}</p>
</body>
</html>
[/code]
ext-web/docroot/html/portlet/ext/springmvc/index.jsp
[code]
<html>
<body>
<p>Hi</p>
</body>
</html>
[/code]
ext-web/docroot/WEB-INF/springmvc-servlet.xml
[code]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean name="/hello_world.html" class="com.ext.portlet.springmvc.HelloWorldController"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
[/code]
ext-web/docroot/WEB-INF/portlet-ext.xml
[code]
<portlet>
<portlet-name>springmvc</portlet-name>
<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>Simple JSP Portlet</title>
</portlet-info>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
[/code]
ext-web/docroot/WEB-INF/web.xml
[code]
<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>
jsp/index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
[/code]
Are there some mistakes?
I get this error, when I try to deploy:
[code]
Website OC4J 10g (10.1.3) Default Web Site definiert ist. Error creating bean w
ith name 'com.liferay.portal.kernel.captcha.CaptchaUtil' defined in class path r
esource [META-INF/util-spring.xml]: Cannot create inner bean 'com.liferay.portal
.captcha.CaptchaImpl#1424b7b' of type [com.liferay.portal.captcha.CaptchaImpl] w
hile setting bean property 'captcha'; nested exception is org.springframework.be
ans.factory.BeanCreationException: Error creating bean with name 'com.liferay.po
rtal.captcha.CaptchaImpl#1424b7b' defined in class path resource [META-INF/util-
spring.xml]: Instantiation of bean failed; nested exception is org.springframewo
rk.beans.BeanInstantiationException: Could not instantiate bean class [com.lifer
ay.portal.captcha.CaptchaImpl]: Constructor threw exception; nested exception is
java.lang.NullPointerException
[/code]
Hope anybody can help me...
Thank you very much.
Best regards,
Johannes