Title: TilesConfigurer throws NoClassDefFoundError on initialization
Tags: spring;spring-mvc;tiles2;apache-tiles
Question: Problem: TilesConfigurer throws NoClassDefFoundError on initialization

Took steps to resolve:


Import tiles jars.
Added jstl.jar
Added older vesions of tiles:
tiles-api-2.0.6.jar
tiles-core-2.0.6.jar
tiles-jsp-2.0.6.jar
tiles-servlet-2.1.2.jar
Several restructuring of web deployments and ordering of imported jars.


webmvc-context.xml

```<?xml version="1.0" encoding="UTF-8"?&gt;
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/mvc
                           http://www.springframework.org/schema/mvc/spring-mvc.xsd"&gt;

    <mvc:view-controller path="/jsp/index.jsp" /&gt;
    <mvc:view-controller path="/jsp/info/about.jsp" /&gt;

<bean id="tilesConfigurer"
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;
        <property name="factoryClass"
            value="org.apache.struts.tiles.xmlDefinition.I18nFactorySet" /&gt;
        <property name="definitions"&gt;
            <list&gt;
                <value&gt;/WEB-INF/tiles-def.xml</value&gt;
            </list&gt;
        </property&gt;
    </bean&gt;


    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" &gt;
              <!--
             <property name="requestContextAttribute" value="requestContext"/&gt;
             <property name="viewClass"
                value="org.springframework.web.servlet.view.tiles.TilesView"/&gt;
                --&gt;
     </bean&gt;
</beans&gt;
```

web.xml

```<?xml version="1.0" encoding="UTF-8"?&gt;
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0" metadata-complete="true"&gt;

    <display-name&gt;simple-tiles2</display-name&gt;

    <listener&gt;
        <listener-class&gt;
            org.springframework.web.context.ContextLoaderListener
        </listener-class&gt;
    </listener&gt;

    <context-param&gt;
        <param-name&gt;contextConfigLocation</param-name&gt;
        <param-value&gt;
            /WEB-INF/spring/web-application-context.xml
        </param-value&gt;
    </context-param&gt;

    <servlet&gt;
        <servlet-name&gt;tiles</servlet-name&gt;
        <servlet-class&gt;org.springframework.web.servlet.DispatcherServlet</servlet-class&gt;
        <init-param&gt;
            <param-name&gt;contextConfigLocation</param-name&gt;
            <param-value&gt;</param-value&gt;
        </init-param&gt;
    </servlet&gt;

    <servlet-mapping&gt;
        <servlet-name&gt;tiles</servlet-name&gt;
        <url-pattern&gt;*.html</url-pattern&gt;
    </servlet-mapping&gt;

    <welcome-file-list&gt;
        <welcome-file&gt;index.jsp</welcome-file&gt;
    </welcome-file-list&gt;

    <filter&gt;
    <filter-name&gt;encoding-filter</filter-name&gt;
      <filter-class&gt;
        org.springframework.web.filter.CharacterEncodingFilter
      </filter-class&gt;
      <init-param&gt;
        <param-name&gt;encoding</param-name&gt;
        <param-value&gt;UTF-8</param-value&gt;
      </init-param&gt;
    </filter&gt;

    <filter-mapping&gt;
      <filter-name&gt;encoding-filter</filter-name&gt;
      <url-pattern&gt;/*</url-pattern&gt;
    </filter-mapping&gt;

</web-app&gt;
```

Error Log Brief:

```13:26:51,622 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-1) Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@136d1b4: defining beans [org.springframework.web.servlet.config.viewControllerHandlerMapping,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,tilesConfigurer,viewResolver]; root of factory hierarchy
13:26:51,627 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-1) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/spring/webmvc-context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/web/servlet/view/tiles2/TilesConfigurer$SpringTilesInitializer
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1011) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:957) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [spring-context-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [rt.jar:1.6.0_43]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [rt.jar:1.6.0_43]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_43]
Caused by: java.lang.NoClassDefFoundError: org/springframework/web/servlet/view/tiles2/TilesConfigurer$SpringTilesInitializer
    at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.6.0_43]
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2398) [rt.jar:1.6.0_43]
    at java.lang.Class.getConstructor0(Class.java:2708) [rt.jar:1.6.0_43]
    at java.lang.Class.getDeclaredConstructor(Class.java:1987) [rt.jar:1.6.0_43]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:78) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1004) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    ... 21 more
Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.view.tiles2.TilesConfigurer$SpringTilesInitializer from [Module "deployment.simple-tiles2-webapp.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    ... 27 more
```





I have used other versions of spring, but right now I am using 3.2.0.RELEASE.  Really appreciate the help.

Comment: Which version of Spring are you using?

Comment: Can you post your pom.xml if you use maven or the list of jar you are using if you don't

Comment: I should have also said that this comes from the springbyexample tutorial.  http://www.springbyexample.org/examples/simple-tiles-spring-mvc-webapp.html

Comment: I have made some edits to my question to give the clarifications you need.  I am using the 3.2.0.RELEASE version of spring and the libraries posted above.  Really appreciate the help.

Here is the accepted answer: Changed two things in webmvc-context.xml.

```<mvc:view-controller path="/index.html" view-name="index" /&gt;
<mvc:view-controller path="/about.html" view-name="info/index" /&gt;
```

and the tilesConfigurer and viewResolver beans

```    <bean id="tilesConfigurer"
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;
        <property name="definitions"&gt;
            <list&gt;
                <value&gt;/WEB-INF/tiles-defs/templates.xml</value&gt;
            </list&gt;
        </property&gt;
    </bean&gt;

   <bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
    <property name="viewClass"&gt;
        <value&gt;
            org.springframework.web.servlet.view.tiles2.TilesView
        </value&gt;
    </property&gt;
   </bean&gt;
```

There were also libraries that were changed. I don't think that is relevant, but here they are.





{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:01/17/14', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<spring><spring-mvc><tiles2><apache-tiles>', 'Title': 'TilesConfigurer throws NoClassDefFoundError on initialization', 'ViewCount': 7852, 'id': 21195294, 'user_AboutMe': '<p>With my Computer Science Degree from Southwest Baptist University I was introduced to web development through my senior project. We developed a application for Food Pantries to process their applicants and get them assistance.</p>\n\n<p>more about me on my blog <a href="http://www.onemeonecard.com" rel="nofollow">onemeonecard.com</a></p>\n', 'user_AccountId': 1481019.0, 'user_DisplayName': 'bearcatFulton', 'user_Reputation': 71.0, 'user_Views': 101.0, 'user_id': 1390421.0}}