Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-6338

New template scripts on the classpath are not loaded

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Critical Critical
    • 5.4.4, 5.4.5
    • 5.4
    • resource-loader
    • None

      Resources on the classpath are not observed, except the YAML ones.
      Hence new files, e.g. template-scripts are not found until restart.
      As part of this issue, We will also handle newly added and deleted resources.
      Also ClasspathResourceOrigin is serving resources from cache, and thus, one would never find any created resource after the system startup.
      We will change this and serve resources if they are actually present.


      Original description:

      Situation:

      In a checked out JAR/Maven module in the IDE (Eclipse in this case)
      Having there the inner new module structure as:
      /src/main/resources/%moduleName%/templates etc.

      Behavior in 5.3.x:
      • One could create on the fly a ftl file in:
        /src/main/resources/foo/test.ftl
        And use it in a template def as: /foo/test.ftl
        Worked perfect
      Behavior in 5.4.0:
      • create new ftl in: /src/main/resources/foo/test.ftl
        (old pattern) or /src/main/resources/%moduleName%/templates/foo/test.ftl (new pattern)
        And use it in a template def
        Does not work anymore -> needs server restart
        Also resources app doesn't show it until restart.
      • new yaml files created in: /%moduleName%/templates/...
        are properly found
      • Existing ftl files during startup are loaded correctly on changes.
      • In the directory where magnolia.resources.dir=${magnolia.home} points to new ftl's are found on the fly correctly.
      Stack trace:
      "2015-08-06 16:59:13,031 INFO  agnolia.config.source.yaml.YamlConfigurationSource: Registered DefinitionMetadataBuilder.DefinitionMetadataImpl(type=TEMPLATE, referenceId=travel-demo:pages/home2, name=home2, module=travel-demo, location=/travel-demo/templates/pages/home2.yaml, relativeLocation=pages/home2) from LayeredResource{path='/travel-demo/templates/pages/home2.yaml', layeredResources=[ClasspathResource{path=/travel-demo/templates/pages/home2.yaml}]}
      2015-08-06 16:59:40,800 ERROR ndering.engine.ModeDependentRenderExceptionHandler: Error while rendering [/test2] with template [travel-demo:pages/home2] for URI [/test2.html?mgnlPreview=false&mgnlChannel=desktop]:
      RenderException: java.io.FileNotFoundException: Template "/travel-demo/templates/pages/main2.ftl" not found. The quoted name was interpreted by this template loader: info.magnolia.freemarker.FreemarkerHelper$ConfigDelegatingTemplateLoader@d0bb7d8.
      info.magnolia.rendering.engine.RenderException: java.io.FileNotFoundException: Template "/travel-demo/templates/pages/main2.ftl" not found. The quoted name was interpreted by this template loader: info.magnolia.freemarker.FreemarkerHelper$ConfigDelegatingTemplateLoader@d0bb7d8.
              at info.magnolia.rendering.renderer.FreemarkerRenderer.onRender(FreemarkerRenderer.java:100)
              at info.magnolia.rendering.renderer.AbstractRenderer.render(AbstractRenderer.java:155)
              at info.magnolia.rendering.engine.DefaultRenderingEngine.render(DefaultRenderingEngine.java:118):
      

      With proposed solution;

      • Introduced magnolia.resources.classpath.observation.pattern property. With this property, we gave user a way to handle which files they would like us to observe for them. Given a user wants ftl files to be observed, they can just add it to the observation pattern.
      • Detection of added/deleted files and handling the properly
      • Deleted files are reflected in the resources-app properly {with help of MGNLRES-240}

        as well.

      • Serving files upon request if they are present.

        Acceptance criteria

              ilgun Ilgun Ilgun
              cringele Christian Ringele
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0d
                    0d
                    Logged:
                    Time Spent - 7h
                    7h