Page 1 of 1

Error resolving template "blStaticAssetView" [FIXED]

Posted: Fri Apr 19, 2013 8:19 am
by staleks
Hi,

I am wondering what I am doing wrong?

GOAL: In my FrontEnd application (site) I want to enable feature: Show files that are uploaded from BO application (admin) - StaticAssets

What I've done so far:
1. Added broadleaf-contentmanagement-module in pom.xml (site)
2. Ensured that CMS application context is loading ...
added: classpath:/applicationContext-servlet-cms-contentClient.xml in web.xml
3. Made sure that configuration param is loading while application context is loading:
asset.server.url.prefix.internal=cmsstatic
4. In debug mode, I am sure that /**/cmsstatic/** BroadleafCMSHAndlerMapping is created


Application starts fine and works correctly until the moment when I want to show file uploaded in Admin.

I've debuged and 100% sure that logic of converting BLOB field from DB to file system works correctly. I can see file at /tmp/ folder, and method

Code: Select all

staticAssetStorageService.getCacheFileModel
of StaticAssetViewController.class
shows correct fullUrl.

Now the problem lies in fact that appliccation doesn't know how to handle viewResolverName.

In debug I see that viewResolverName is ok ("blStaticAssetView") but once it is triggered I am getting following error:

Code: Select all

Error resolving template "blStaticAssetView", template might not exist or might not be accessible by any of the configured Template Resolvers


In order to give you some more light to my problem I must state that I am using Thymyleaf.


Does someone has any idea what is going on?

Thank You

Re: Error resolving template "blStaticAssetView"

Posted: Mon Apr 22, 2013 10:35 am
by phillipuniverse
Looks like the part that makes this work is in applicationContext-servlet-cms-contentClient.xml:

Code: Select all

    <!-- This resolver locates the "blStaticAssetView" ViewResolver using its bean name. -->
    <bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
        <property name="order" value="1"/>
    </bean>


Are you sure that this contentClient.xml file is declared in the servlet context and not patchConfigLocations? For instance:

Code: Select all

    <servlet>
        <servlet-name>mycompany</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                classpath:/applicationContext-servlet-cms-contentClient.xml
                /WEB-INF/applicationContext-servlet.xml
            </param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>


Sometimes these beans must be declared in the servlet rather than the root context for them to work (handler mappings fall under the same category).

Re: Error resolving template "blStaticAssetView"

Posted: Wed Apr 24, 2013 4:17 am
by staleks
OK,

You were right,
"applicationContext-servlet-cms-contentClient.xml"

should be defined as part of DispatcherServlet and not as part of "patchConfigLocation" in web.xml.

Then it works, and /**/cmsstatic/** is now handled by CMS.

Thank You