Announcement Announcement Module
Collapse
No announcement yet.
Spring Portlet MVC with Freemarker Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Portlet MVC with Freemarker

    Dears,
    I'm trying a basic "Hello Freemarker Portlet" with no luck. The deployment of the portlet in Liferay 6.0 goes fine. But when I'm trying to add the portlet to a page, I got the following exception:
    Code:
    java.lang.NullPointerException
    	at org.springframework.web.servlet.view.freemarker.FreeMarkerView.getTemplate(FreeMarkerView.java:350)
    	at org.springframework.web.servlet.view.freemarker.FreeMarkerView.checkResource(FreeMarkerView.java:203)
    	at org.springframework.web.servlet.view.UrlBasedViewResolver.loadView(UrlBasedViewResolver.java:421)
    	at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:158)
    	at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(UrlBasedViewResolver.java:384)
    	at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:69)
    	at org.springframework.web.portlet.DispatcherPortlet.resolveViewName(DispatcherPortlet.java:1110)
    	at org.springframework.web.portlet.DispatcherPortlet.render(DispatcherPortlet.java:1052)
    	at org.springframework.web.portlet.DispatcherPortlet.doRenderService(DispatcherPortlet.java:761)
    	at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:522)
    	at org.springframework.web.portlet.FrameworkPortlet.doDispatch(FrameworkPortlet.java:470)
    	at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
    ...
    web.xml
    Code:
    <web-app
    	xmlns="http://java.sun.com/xml/ns/j2ee"
    	version="2.4"
    	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
    	"
    >
    	<servlet>
    		<servlet-name>view-servlet</servlet-name>
    		<servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>view-servlet</servlet-name>
    		<url-pattern>/WEB-INF/servlet/view</url-pattern>
    	</servlet-mapping>
    </web-app>
    portlet.xml
    Code:
    <portlet-app
    	xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	version="2.0"
    	xsi:schemaLocation="
    		http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
    			http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
    	"
    >
    	<portlet>
    		<portlet-name>handson-portlet-spring-freemarker</portlet-name>
    		<portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
    		<init-param>
    			<name>contextConfigLocation</name>
    			<value>/WEB-INF/handson-portlet-spring-freemarker-portlet.xml</value>
    		</init-param>
    		<supports>
    			<mime-type>text/html</mime-type>
    			<portlet-mode>view</portlet-mode>
    		</supports>
    		<resource-bundle>Language-ext</resource-bundle>
    		<portlet-info>
    			<title>Handson::Portlet::Spring::Freemarker</title>
    		</portlet-info>
    	</portlet>	
    </portlet-app>
    Application-context.xml
    Code:
    <beans
    	xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:p="http://www.springframework.org/schema/p"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:util="http://www.springframework.org/schema/util"
    	xsi:schemaLocation="
    		http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    		http://www.springframework.org/schema/context
    			http://www.springframework.org/schema/context/spring-context-3.0.xsd
    		http://www.springframework.org/schema/util
    			http://www.springframework.org/schema/util/spring-util-3.0.xsd
    	"
    >
    	<context:component-scan base-package="handson.portlet.spring" />
    
    	<bean
    		id="freemarkerConfig"
    		class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"
    		p:templateLoaderPath="/WEB-INF/freemarker/"
    	/>
    	<bean
    		id="viewResolver"
    		class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"
    		p:viewClass="org.springframework.web.servlet.view.freemarker.FreeMarkerView"
    		p:suffix=".ftl"
    	/>
    </beans>
    Thank you in advance.

    Younes

  • #2
    Hi younes.
    Have you any solution on your trouble?

    Comment


    • #3
      Hi buslovskas,

      Not at all. I have got a reply through JIRA saying that the issue is due to Freemarker not Spring Portlet MVC and hence can be resolved only by Freemarker team. I have stopped at that level.

      However, a comment has been add by Barrie Selack to the JIRA (see https://jira.springsource.org/browse/SPR-7830). I hope it will help.

      Warm regards.

      Younes

      Comment

      Working...
      X