tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hernán <heam...@gmail.com>
Subject Struts 2 Tiles 2 Freemarker Integration
Date Wed, 28 Jul 2010 21:48:10 GMT
As I try to configure freemarker with struts 2 when I add the method
registerAttributeRenderers to a class that extends
BasicTilesContainerFactory I get an error I cannot resolve.

package ro.tiles;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.apache.tiles.TilesApplicationContext;
import org.apache.tiles.TilesContainer;
import org.apache.tiles.context.TilesRequestContextFactory;
import org.apache.tiles.evaluator.AttributeEvaluatorFactory;
import org.apache.tiles.factory.BasicTilesContainerFactory;
import org.apache.tiles.freemarker.renderer.FreeMarkerAttributeRenderer;
import org.apache.tiles.renderer.impl.BasicRendererFactory;

public class RoTilesFactory extends BasicTilesContainerFactory {

    @Override
    protected List<URL> getSourceURLs(TilesApplicationContext
tilesApplicationContext,
            TilesRequestContextFactory tilesRequestContextFactory) {

        List<URL> urls = null;

        try {
            urls = new ArrayList<URL>();

urls.add(tilesApplicationContext.getResource("/WEB-INF/tiles_en_US.xml"));
        } catch(Exception exception) {

        }

        return urls;
    }

    @Override
    protected void registerAttributeRenderers(
            BasicRendererFactory rendererFactory,
            TilesApplicationContext applicationContext,
            TilesRequestContextFactory contextFactory,
            TilesContainer container,
            AttributeEvaluatorFactory attributeEvaluatorFactory)
    {
        FreeMarkerAttributeRenderer freemarkerRenderer = new
FreeMarkerAttributeRenderer();
        freemarkerRenderer.setApplicationContext(applicationContext);

freemarkerRenderer.setAttributeEvaluatorFactory(attributeEvaluatorFactory);
        freemarkerRenderer.setRequestContextFactory(contextFactory);
        freemarkerRenderer.setParameter("TemplatePath", "/WEB-INF/ftl/");
        freemarkerRenderer.setParameter("NoCache", "true");
        freemarkerRenderer.setParameter("ContentType", "text/html");
        freemarkerRenderer.setParameter("template_update_delay", "0");
        freemarkerRenderer.setParameter("default_encoding", "ISO-8859-1");
        freemarkerRenderer.setParameter("number_format", "0.##########");
        freemarkerRenderer.commit();
        rendererFactory.registerRenderer("freemarker", freemarkerRenderer);
    }

}


org.apache.tiles.reflect.CannotInstantiateObjectException: Unable to resolve
factory class: 'definition'
    at org.apache.tiles.reflect.ClassUtil.instantiate(ClassUtil.java:109)
    at org.apache.tiles.reflect.ClassUtil.instantiate(ClassUtil.java:82)
    at
org.apache.tiles.renderer.impl.BasicRendererFactory.getRenderer(BasicRendererFactory.java:181)
    at
org.apache.tiles.factory.BasicTilesContainerFactory.createDefaultAttributeRenderer(BasicTilesContainerFactory.java:438)
    at
org.apache.tiles.factory.BasicTilesContainerFactory.createRendererFactory(BasicTilesContainerFactory.java:413)
    at
org.apache.tiles.factory.BasicTilesContainerFactory.createContainer(BasicTilesContainerFactory.java:111)
    at
org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:124)
    at
org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
    at
org.apache.tiles.web.startup.AbstractTilesInitializerServlet.init(AbstractTilesInitializerServlet.java:61)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
    at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: definition
    at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
    at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.apache.tiles.reflect.ClassUtil.getClass(ClassUtil.java:67)
    at org.apache.tiles.reflect.ClassUtil.instantiate(ClassUtil.java:103)
    ... 26 more
Jul 28, 2010 6:35:17 PM org.apache.catalina.core.StandardContext
loadOnStartup
SEVERE: Servlet /RemOpt threw load() exception
java.lang.ClassNotFoundException: definition
    at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
    at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at org.apache.tiles.reflect.ClassUtil.getClass(ClassUtil.java:67)
    at org.apache.tiles.reflect.ClassUtil.instantiate(ClassUtil.java:103)
    at org.apache.tiles.reflect.ClassUtil.instantiate(ClassUtil.java:82)
    at
org.apache.tiles.renderer.impl.BasicRendererFactory.getRenderer(BasicRendererFactory.java:181)
    at
org.apache.tiles.factory.BasicTilesContainerFactory.createDefaultAttributeRenderer(BasicTilesContainerFactory.java:438)
    at
org.apache.tiles.factory.BasicTilesContainerFactory.createRendererFactory(BasicTilesContainerFactory.java:413)
    at
org.apache.tiles.factory.BasicTilesContainerFactory.createContainer(BasicTilesContainerFactory.java:111)
    at
org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:124)
    at
org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
    at
org.apache.tiles.web.startup.AbstractTilesInitializerServlet.init(AbstractTilesInitializerServlet.java:61)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
    at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
-- 
Hernán

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message