Disable multilingual option in Apache tiles 3
Asked Answered
W

2

6

I am getting following warning with Apche tiles 3 and Spring MVC 4 I does not added any extra configurations for multilingual support but it supporting by default. Can any one help me to disable this option to remove this warning in my site.

    org.apache.tiles.request.locale.PostfixedApplicationResource.
<init> No supported matching language for locale "sw". 
Using file:/opt/apache-tomcat-8.0.35/webapps/ROOT/WEB-INF/tiles/app-core_sw.xml as a non-localized resource path. see TILES-571
Water answered 28/9, 2016 at 7:14 Comment(0)
P
6

You can disable this option by writing your own DefinitionFactory implementation and registering the same in TilesConfigurer.

public class CustomLocaleDefinitionsFactory extends LocaleDefinitionsFactory {

    /** {@inheritDoc} */
    @Override
    public Definition getDefinition(String name, Request tilesContext) {
    Definition retValue;
    Locale locale = null;

    retValue = definitionDao.getDefinition(name, locale);
    if (retValue != null) {
      retValue = new Definition(retValue);
      String parentDefinitionName = retValue.getExtends();
      while (parentDefinitionName != null) {
        Definition parent = definitionDao.getDefinition(parentDefinitionName, locale);
        if (parent == null) {
          throw new NoSuchDefinitionException("Cannot find definition '" + parentDefinitionName
              + "' ancestor of '" + retValue.getName() + "'");
        }
        retValue.inherit(parent);
        parentDefinitionName = parent.getExtends();
      }
    }

    return retValue;
    }
}

And then in register the above definition factor class, in TilesConfigurer in case using spring like this.

TilesConfigurer configurer = new TilesConfigurer();
configurer.setDefinitions(new String[] { "/WEB-INF/layouts/tiles.xml",
    "/WEB-INF/views/**/tiles.xml" });
configurer.setCheckRefresh(true);
configurer.setDefinitionsFactoryClass(CustomLocaleDefinitionsFactory.class);
return configurer;
Primus answered 21/11, 2016 at 22:6 Comment(0)
S
1

There is a workaround, just disable the log output will do, if you are using spring boot, it is very easy:

logging.level.org.apache.tiles.request.locale.PostfixedApplicationResource=ERROR
Suffragan answered 26/7, 2018 at 10:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.