Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Trunk
    • Fix Version/s: 14.12.01, 16.11.01
    • Component/s: birt
    • Labels:
      None
    • Sprint:
      Bug Crush Event - 21/2/2015

      Description

      Birt report does't work anymore.

      access following url: http://demo-trunk-ofbiz.apache.org/birt/control/Report.
      error cut out :

      FreeMarker template error: Could not find an instance of freemarker.ext.servlet.ServletContextHashModel in the data model under either the name _FreeMarkerServlet.Application_ or Application ---- FTL stack trace ("~" means nesting-related): - Failed at: @birt.report id="birtReport" reportDe... [in template "component://birt/webapp/birt/birt/chartReport.ftl" at line 22, column 1] ---- Java stack trace (for programmers): ---- freemarker.template.TemplateModelException: [... Exception message was already printed; see it above ...] at freemarker.ext.jsp.FreeMarkerPageContext.<init>(FreeMarkerPageContext.java:92) at freemarker.ext.jsp._FreeMarkerPageContext21.<init>(_FreeMarkerPageContext21.java:53) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at

        Issue Links

          Activity

          Hide
          utcb Leon added a comment -

          workaround:

          Show
          utcb Leon added a comment - workaround: revert the commit r1621801 https://fisheye6.atlassian.com/changelog/ofbiz?cs=1621801 , since ServletContextHashModel is being used by Birt, not the unused stuff. revert the commit r1621953 to ControlServlet.java https://fisheye6.atlassian.com/changelog/ofbiz?cs=1621953 to import necessary packages add "commons-discovery-0.4.jar" back to framework/base/lib/commons, or add it to specialpurpose/birt/lib folder, since it's depended by axis-1.4 https://fisheye6.atlassian.com/changelog/ofbiz?cs=1623042
          Hide
          jacques.le.roux Jacques Le Roux added a comment - - edited

          Thanks Leon,

          For now at least "commons-discovery-0.4.jar" has been added in specialpurpose/birt/lib folder (see OFBIZ-5876). OFBIZ-5876 was not a duplicate of OFBIZ-5870. So the 2 other actions you proposed need to be considered...

          Show
          jacques.le.roux Jacques Le Roux added a comment - - edited Thanks Leon, For now at least "commons-discovery-0.4.jar" has been added in specialpurpose/birt/lib folder (see OFBIZ-5876 ). OFBIZ-5876 was not a duplicate of OFBIZ-5870 . So the 2 other actions you proposed need to be considered...
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          Hi Leon,

          Using trunk HEAD, despite reverting these 2 changes, so having

          Index: ControlServlet.java
          ===================================================================
          --- ControlServlet.java	(revision 1659774)
          +++ ControlServlet.java	(working copy)
          @@ -37,6 +37,7 @@
           import org.ofbiz.base.util.UtilHttp;
           import org.ofbiz.base.util.UtilTimer;
           import org.ofbiz.base.util.UtilValidate;
          +import org.ofbiz.base.util.template.FreeMarkerWorker;
           import org.ofbiz.entity.Delegator;
           import org.ofbiz.entity.DelegatorFactory;
           import org.ofbiz.entity.GenericDelegator;
          @@ -49,6 +50,8 @@
           import org.ofbiz.webapp.stats.VisitHandler;
           import org.ofbiz.entity.util.EntityClassLoader;
           
          +import freemarker.ext.servlet.ServletContextHashModel;
          +
           /**
            * ControlServlet.java - Master servlet for the web application.
            */
          @@ -191,6 +194,9 @@
           
                   request.setAttribute("_REQUEST_HANDLER_", requestHandler);
                   
          +        ServletContextHashModel ftlServletContext = new ServletContextHashModel(this, FreeMarkerWorker.getDefaultOfbizWrapper());
          +        request.setAttribute("ftlServletContext", ftlServletContext);
          +
                   // setup some things that should always be there
                   UtilHttp.setInitialRequestInfo(request);
                   VisitHandler.getVisitor(request, response);
          

          I still get the same error. Maybe there is another change since which prevent things to work as when you tested? Though like you I found only those 2 changes. Could you please check on your side? Thanks!

          Show
          jacques.le.roux Jacques Le Roux added a comment - Hi Leon, Using trunk HEAD, despite reverting these 2 changes, so having Index: ControlServlet.java =================================================================== --- ControlServlet.java (revision 1659774) +++ ControlServlet.java (working copy) @@ -37,6 +37,7 @@ import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilTimer; import org.ofbiz.base.util.UtilValidate; + import org.ofbiz.base.util.template.FreeMarkerWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericDelegator; @@ -49,6 +50,8 @@ import org.ofbiz.webapp.stats.VisitHandler; import org.ofbiz.entity.util.EntityClassLoader; + import freemarker.ext.servlet.ServletContextHashModel; + /** * ControlServlet.java - Master servlet for the web application. */ @@ -191,6 +194,9 @@ request.setAttribute( "_REQUEST_HANDLER_" , requestHandler); + ServletContextHashModel ftlServletContext = new ServletContextHashModel( this , FreeMarkerWorker.getDefaultOfbizWrapper()); + request.setAttribute( "ftlServletContext" , ftlServletContext); + // setup some things that should always be there UtilHttp.setInitialRequestInfo(request); VisitHandler.getVisitor(request, response); I still get the same error. Maybe there is another change since which prevent things to work as when you tested? Though like you I found only those 2 changes. Could you please check on your side? Thanks!
          Hide
          utcb Leon added a comment -

          Hi Jacques,

          You should revert the changes to ScreenRenderer.java too. Since that class has been re-factoried a lot, I paste the patch to current version as below:

          Index: framework/widget/src/org/ofbiz/widget/renderer/ScreenRenderer.java
          ===================================================================
          — framework/widget/src/org/ofbiz/widget/renderer/ScreenRenderer.java (revision 1662639)
          +++ framework/widget/src/org/ofbiz/widget/renderer/ScreenRenderer.java (working copy)
          @@ -63,6 +63,7 @@
          import freemarker.ext.jsp.TaglibFactory;
          import freemarker.ext.servlet.HttpRequestHashModel;
          import freemarker.ext.servlet.HttpSessionHashModel;
          +import freemarker.ext.servlet.ServletContextHashModel;

          /**

          • Widget Library - Screen model class
            @@ -246,7 +247,11 @@
            TaglibFactory JspTaglibs = new TaglibFactory(servletContext);
            context.put("JspTaglibs", JspTaglibs);
            context.put("requestParameters", UtilHttp.getParameterMap(request));
          • +
            + ServletContextHashModel ftlServletContext = (ServletContextHashModel) request.getAttribute("ftlServletContext");
            + context.put("Application", ftlServletContext);
            + context.put("Request", context.get("requestAttributes"));
            +
            // this is a dummy object to stand-in for the JPublish page object for backward compatibility
            context.put("page", new HashMap());

          Show
          utcb Leon added a comment - Hi Jacques, You should revert the changes to ScreenRenderer.java too. Since that class has been re-factoried a lot, I paste the patch to current version as below: Index: framework/widget/src/org/ofbiz/widget/renderer/ScreenRenderer.java =================================================================== — framework/widget/src/org/ofbiz/widget/renderer/ScreenRenderer.java (revision 1662639) +++ framework/widget/src/org/ofbiz/widget/renderer/ScreenRenderer.java (working copy) @@ -63,6 +63,7 @@ import freemarker.ext.jsp.TaglibFactory; import freemarker.ext.servlet.HttpRequestHashModel; import freemarker.ext.servlet.HttpSessionHashModel; +import freemarker.ext.servlet.ServletContextHashModel; /** Widget Library - Screen model class @@ -246,7 +247,11 @@ TaglibFactory JspTaglibs = new TaglibFactory(servletContext); context.put("JspTaglibs", JspTaglibs); context.put("requestParameters", UtilHttp.getParameterMap(request)); + + ServletContextHashModel ftlServletContext = (ServletContextHashModel) request.getAttribute("ftlServletContext"); + context.put("Application", ftlServletContext); + context.put("Request", context.get("requestAttributes")); + // this is a dummy object to stand-in for the JPublish page object for backward compatibility context.put("page", new HashMap());
          Hide
          jacques.le.roux Jacques Le Roux added a comment -

          Thanks Leon,

          Fixed in
          trunk r1662812
          R14.12 r1662822

          I don't know how I missed the 2nd part :/

          Show
          jacques.le.roux Jacques Le Roux added a comment - Thanks Leon, Fixed in trunk r1662812 R14.12 r1662822 I don't know how I missed the 2nd part :/

            People

            • Assignee:
              jacques.le.roux Jacques Le Roux
              Reporter:
              utcb Leon
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development

                  Agile