Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-7830

Freemarker View fail when used in a Spring Portlet MVC application

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 3.0.3
    • Fix Version/s: None
    • Component/s: Web
    • Labels:
      None

      Description

      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:
      {{

      {Caused by: 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) ... 112 more}

      }}

      Please, see the attachment for the full application. It is an Eclipse/Maven2 application.

      Warm regards

      Younes

        Activity

        Hide
        juergen.hoeller Juergen Hoeller added a comment -

        I'm afraid this is not supported at the moment since FreeMarkerView (like FreeMarker's own web support) strongly depends on getting initialized with a ServletContext. We'll revisit this for Spring 3.1.

        Juergen

        Show
        juergen.hoeller Juergen Hoeller added a comment - I'm afraid this is not supported at the moment since FreeMarkerView (like FreeMarker's own web support) strongly depends on getting initialized with a ServletContext. We'll revisit this for Spring 3.1. Juergen
        Hide
        bselack Barrie Selack added a comment -

        I was able to get a Freemarker view working by adding this to the web.xml (using 3.0.3)

        <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

        Had the following jars in my portlet...

        spring-asm.jar
        spring-beans.jar
        spring-context.jar
        spring-context-support.jar
        spring-core.jar
        spring-expression.jar
        spring-web-portlet.jar
        spring-web-servlet.jar
        spring-web.jar

        Hopefully it will help someone else!

        Show
        bselack Barrie Selack added a comment - I was able to get a Freemarker view working by adding this to the web.xml (using 3.0.3) <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> Had the following jars in my portlet... spring-asm.jar spring-beans.jar spring-context.jar spring-context-support.jar spring-core.jar spring-expression.jar spring-web-portlet.jar spring-web-servlet.jar spring-web.jar Hopefully it will help someone else!
        Hide
        prikryl petr added a comment - - edited
        Show
        prikryl petr added a comment - - edited Hello, did you fix this issue in 3.1.x? It seems to be still there... Or is there any brief description where is problem? The last workaroud is not working any more http://charles.forsythe.name/home/-/blogs/liferay-6-1-1-on-tomcat-breaks-spring-and-freemarker-quick-fix-edition?_33_redirect=http%3A%2F%2Fcharles.forsythe.name%2Fhome%3Fp_p_id%3D33%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_count%3D1 Thank you

          People

          • Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            younes Younes Ouadi
            Last updater:
            Juergen Hoeller
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              4 years, 26 weeks, 6 days ago

              Time Tracking

              Estimated:
              Original Estimate - 1d
              1d
              Remaining:
              Remaining Estimate - 1d
              1d
              Logged:
              Time Spent - Not Specified
              Not Specified