java.lang.IllegalArgumentException: Cannot find a factory to create the request context

Code Chieftain

I am tiring to use spring boot,thymeleaf and tiles in my project ,but i just keep getting the titled error.

stacktrace error is

java.lang.IllegalArgumentException: Cannot find a factory to create the request context
    at org.apache.tiles.context.ChainedTilesRequestContextFactory.createRequestContext(ChainedTilesRequestContextFactory.java:137)
    at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:317)
    at org.thymeleaf.extras.tiles2.spring4.web.view.ThymeleafTilesView.render(ThymeleafTilesView.java:125)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1221)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1005)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:952)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

my pom.xml

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.1.9.RELEASE</version>
       <relativePath /> 
    </parent>
    <groupId>Supporter</groupId>
    <artifactId>Supporter</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <name>Supporter</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <start-class>com.test.supporter.Application</start-class>
        <java.version>1.7</java.version>
        <main.basedir>${basedir}/../..</main.basedir>
        <m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
        <thymeleaf.version>2.1.3.RELEASE</thymeleaf.version>
        <tiles.version>2.2.2</tiles.version>
    </properties>
     <dependencies>
       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>   
       <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf-spring4</artifactId>
            <version>${thymeleaf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf</groupId>
            <artifactId>thymeleaf</artifactId>
            <version>${thymeleaf.version}</version>
        </dependency>
         <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-tiles2-spring4</artifactId>
            <version>2.1.1.RELEASE</version>
        </dependency> 
         <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-extras</artifactId>
            <version>${tiles.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

The Configration class

@Configuration
public class Configurations {

    @Bean
    public SpringTemplateEngine templateEngine() {
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        Set<TemplateResolver> templateResolvers = new java.util.HashSet<>();
        templateResolvers.add(webTemplateResolver());
        templateEngine.setTemplateResolvers(templateResolvers);
        Set<IDialect> additionalDialects = new HashSet<>();
        additionalDialects.add(new TilesDialect());
        templateEngine.setAdditionalDialects(additionalDialects);
        return templateEngine;
    }

     @Bean
        public ServletContextTemplateResolver webTemplateResolver() {
            ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
            templateResolver.setPrefix("WEB-INF/tiles/templates/");
            templateResolver.setSuffix(".html");
            templateResolver.setTemplateMode("HTML5");
            templateResolver.setCharacterEncoding("UTF-8");
            templateResolver.setOrder(2);
           return templateResolver;
        }
    @Bean
    public TilesConfigurer tilesConfigurer() {
        final TilesConfigurer configurer = new TilesConfigurer();
        configurer.setDefinitions(new String[] { "WEB-INF/tiles/tiles-defs.xml" });
        configurer.setCheckRefresh(true);
        return configurer;
    }
    @Bean
    public TilesViewResolver tilesViewResolver() {
        final TilesViewResolver resolver = new TilesViewResolver();
        resolver.setViewClass(TilesView.class);
        return resolver;
    }
    @Bean
    public ThymeleafViewResolver viewResolver() {
        ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
        viewResolver.setViewClass(ThymeleafTilesView.class);
        viewResolver.setTemplateEngine(templateEngine());
        viewResolver.setCharacterEncoding("UTF-8");
        viewResolver.setOrder(0);//ADDED LINE
        return viewResolver;
    }

Note that : also i have tried to changed the versions of libraries but i got NoClassDefError and tried spring-boot-starter-thymeleaf but no luck .so can any one help please?

Omar NourdeaN

you are using the TilesConfigurer class to config a thymeleaf tiles integration ,TilesConfigurer is used to config a tiles integration with spring only so to config a thymeleaf tiles spring integration you should change the TilesConfigurer to ThymeleafTilesConfigurer that is in the org.thymeleaf.extras.tiles2.spring4.web.configurer package

thus your method should change to

 @Bean
    public ThymeleafTilesConfigurer thymeleafTilesConfigurer(){
        final ThymeleafTilesConfigurer configurer = new ThymeleafTilesConfigurer();
        configurer.setDefinitions(new String[] { "WEB-INF/tiles/tiles-defs.xml" });
        configurer.setCheckRefresh(true);
         return configurer;
    }

Hope thats helps

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

java.lang.IllegalStateException : Could not find backup for factory javax.faces.context.FacesContextFactory

From Dev

java.lang.IllegalStateException:Could not find backup for factory javax.faces.context.FacesContextFactory

From Dev

java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof

From Dev

java.lang.IllegalArgumentException: Cannot format given Object as a Date

From Dev

ByteBuddy: java.lang.IllegalArgumentException: Cannot attach undefined variable: V

From Dev

java.lang.IllegalArgumentException: Cannot register after unregistered Filter class

From Dev

java.lang.illegalargumentexception:cannot set a null TableModel

From Dev

java.lang.IllegalArgumentException: Cannot format given Object as a Date

From Dev

Android java.lang.illegalargumentexception unable to find native library main

From Dev

java.lang.IllegalArgumentException: Failed to find configured root that contains /file:/

From Dev

java.lang.IllegalArgumentException: Unable to instantiate factory class: org.springframework.boot.env.EnvironmentPostProcessor

From Dev

Spring context initialization failed with java.lang.IllegalArgumentException while deploying to Apache 7.0.54 and java 8

From Dev

java.lang.RuntimeException: Unable to start receiver xx.xx.ImediateSMSReceiver: java.lang.IllegalArgumentException: Context must not be null

From Dev

Spring - java.lang.IllegalArgumentException

From Dev

Why is there an java.lang.IllegalArgumentException?

From Dev

java.lang.IllegalArgumentException in adapter

From Dev

Error: java.lang.IllegalArgumentException

From Dev

Facing java.lang.IllegalArgumentException

From Dev

JAVA: java.lang.IllegalArgumentException: Cannot subclass final class class [Lcom.package.testEntityDO;

From Dev

java.lang.IllegalArgumentException: Host name may not be null, while firing a get request

From Dev

java.lang.IllegalArgumentException: FormUrlEncoded can only be specified on HTTP methods with request body (e.g., @POST)

From Dev

AndroidStudio build with Dagger2: java.lang.IllegalArgumentException: ... cannot be represented as a Class<?>

From Dev

How to solve java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0?

From Dev

Spring Boot Security - java.lang.IllegalArgumentException: Cannot pass a null GrantedAuthority collection

From Dev

Spring Boot Security - java.lang.IllegalArgumentException: Cannot pass a null GrantedAuthority collection

From Dev

java.lang.IllegalArgumentException: @Url cannot be used with @GET URL (parameter #1)

From Dev

java.lang.IllegalArgumentException: Cannot determine the graph element type because the document class is null.

From Dev

Spring autowiring: Caused by: java.lang.IllegalArgumentException: Cannot set a null TableModel

From Dev

java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present

Related Related

  1. 1

    java.lang.IllegalStateException : Could not find backup for factory javax.faces.context.FacesContextFactory

  2. 2

    java.lang.IllegalStateException:Could not find backup for factory javax.faces.context.FacesContextFactory

  3. 3

    java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof

  4. 4

    java.lang.IllegalArgumentException: Cannot format given Object as a Date

  5. 5

    ByteBuddy: java.lang.IllegalArgumentException: Cannot attach undefined variable: V

  6. 6

    java.lang.IllegalArgumentException: Cannot register after unregistered Filter class

  7. 7

    java.lang.illegalargumentexception:cannot set a null TableModel

  8. 8

    java.lang.IllegalArgumentException: Cannot format given Object as a Date

  9. 9

    Android java.lang.illegalargumentexception unable to find native library main

  10. 10

    java.lang.IllegalArgumentException: Failed to find configured root that contains /file:/

  11. 11

    java.lang.IllegalArgumentException: Unable to instantiate factory class: org.springframework.boot.env.EnvironmentPostProcessor

  12. 12

    Spring context initialization failed with java.lang.IllegalArgumentException while deploying to Apache 7.0.54 and java 8

  13. 13

    java.lang.RuntimeException: Unable to start receiver xx.xx.ImediateSMSReceiver: java.lang.IllegalArgumentException: Context must not be null

  14. 14

    Spring - java.lang.IllegalArgumentException

  15. 15

    Why is there an java.lang.IllegalArgumentException?

  16. 16

    java.lang.IllegalArgumentException in adapter

  17. 17

    Error: java.lang.IllegalArgumentException

  18. 18

    Facing java.lang.IllegalArgumentException

  19. 19

    JAVA: java.lang.IllegalArgumentException: Cannot subclass final class class [Lcom.package.testEntityDO;

  20. 20

    java.lang.IllegalArgumentException: Host name may not be null, while firing a get request

  21. 21

    java.lang.IllegalArgumentException: FormUrlEncoded can only be specified on HTTP methods with request body (e.g., @POST)

  22. 22

    AndroidStudio build with Dagger2: java.lang.IllegalArgumentException: ... cannot be represented as a Class<?>

  23. 23

    How to solve java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0?

  24. 24

    Spring Boot Security - java.lang.IllegalArgumentException: Cannot pass a null GrantedAuthority collection

  25. 25

    Spring Boot Security - java.lang.IllegalArgumentException: Cannot pass a null GrantedAuthority collection

  26. 26

    java.lang.IllegalArgumentException: @Url cannot be used with @GET URL (parameter #1)

  27. 27

    java.lang.IllegalArgumentException: Cannot determine the graph element type because the document class is null.

  28. 28

    Spring autowiring: Caused by: java.lang.IllegalArgumentException: Cannot set a null TableModel

  29. 29

    java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present

HotTag

Archive