Announcement Announcement Module
Collapse
No announcement yet.
Problem 404 when using tiles Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem 404 when using tiles

    Hi guys,

    I am start to learn how to use tiles and cant get it work. Getting next error when trying to access contacts.html page.

    HTTP Status 404 -

    --------------------------------------------------------------------------------

    type Status report
    message
    description The requested resource is not available.


    My XML conf files:

    web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        id="WebApp_ID" version="2.5">
        <display-name>Spring3MVC</display-name>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list> 
        <servlet>
            <servlet-name>spring</servlet-name>
            <servlet-class>
                org.springframework.web.servlet.DispatcherServlet
            </servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>spring</servlet-name>
            <url-pattern>*.html</url-pattern>
        </servlet-mapping>
    </web-app>
    spring-servlet.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <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:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
    		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     		http://www.springframework.org/schema/context
     		http://www.springframework.org/schema/context/spring-context-3.0.xsd">
     
        <context:component-scan
            base-package="net.viralpatel.spring3.controller" />
             
        <bean 	id="viewResolver"
        		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        	<property name="viewClass">
            	<value>
               		org.springframework.web.servlet.view.tiles2.TilesView
            	</value>
        	</property>
    	</bean>
    	
    	<bean 	id="tilesConfigurer"
        		class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        	<property name="definitions">
            	<list>
    				<value>/WEB-INF/tiles.xml</value>
            	</list>
        	</property>
    	</bean>   
    </beans>
    tiles.xml

    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE tiles-definitions PUBLIC
           "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
           "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
    <tiles-definitions>
        <definition name="base.definition"
            template="/WEB-INF/jsp/layout.jsp">
            <put-attribute name="title" value="" />
            <put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
            <put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />
            <put-attribute name="body" value="" />
            <put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
        </definition>
     
     	
     
        <definition name="contact" extends="base.definition">
            <put-attribute name="title" value="Contact Manager" />
            <put-attribute name="body" value="/WEB-INF/jsp/contact.jsp" />
        </definition>
     
    </tiles-definitions>

    layout.jsp
    Code:
    <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><tiles:insertAttribute name="title" ignore="true" /></title>
    </head>
    <body>
    <table border="1" cellpadding="2" cellspacing="2" align="center">
        <tr>
            <td height="30" colspan="2"><tiles:insertAttribute name="header" />
            </td>
        </tr>
        <tr>
            <td height="250"><tiles:insertAttribute name="menu" /></td>
            <td width="350"><tiles:insertAttribute name="body" /></td>
        </tr>
        <tr>
            <td height="30" colspan="2"><tiles:insertAttribute name="footer" />
            </td>
        </tr>
    </table>
    </body>
    </html>
    I do have all files in jsp folder

    And my Controller
    Code:
    @Controller
    @SessionAttributes
    public class ContactController {
     
        @RequestMapping(value = "/addContact", method = RequestMethod.POST)
        public String addContact(@ModelAttribute("contact")
                                Contact contact, BindingResult result) {
             
            System.out.println("First Name:" + contact.getFirstname() +
            					"Last Name:" + contact.getLastname());
             
            return "redirect:contacts.html";
        }
         
        @RequestMapping("/contacts")
        public ModelAndView showContacts() {         
            return new ModelAndView("contact", "command", new Contact());
        }
    }
    Please any advice.. why I am getting 404 when trying to access contacts.html

  • #2
    just I added to my libs:

    tiles-api-3.0.1.jar
    tiles-core-3.0.1.jar
    tiles-jsp-3.0.1.jar
    tiles-servlet-3.0.1.jar
    tiles-template-3.0.1.jar

    and getting error:

    HTTP Status 500 - Servlet.init() for servlet spring threw exception

    --------------------------------------------------------------------------------

    type Exception report

    message Servlet.init() for servlet spring threw exception

    description The server encountered an internal error that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: Servlet.init() for servlet spring threw exception

    root cause

    java.lang.NoClassDefFoundError: org/apache/tiles/startup/BasicTilesInitializer
    java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClassCond(Unknown Source)
    java.lang.ClassLoader.defineClass(Unknown Source)
    java.s


    root cause

    java.lang.ClassNotFoundException: org.apache.tiles.startup.BasicTilesInitializer
    org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1714)
    org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1559)
    java.lang.ClassLoader.defineClass1(Native Method)
    java.lang.ClassLoader.defineClassCond(Unknown Source)
    java.lang.ClassLoader.defineClass(Unknown Source)
    java.security.SecureClassLoader.defineClass(Unknow n Source)
    org.apache.catalina.loader.WebappClassLoader.findC lassInternal(WebappClassLoader.java:2904)
    org.apache.catalina.loader.WebappClassLoader.findC lass(WebappClassLoader.java:1173)
    org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1681)
    org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1559)
    java.lang.Class.getDeclaredConstructors0(Native Method)
    java.lang.Class.privateGetDeclaredConstructors(Unk nown Source)
    java.lang.Class.getDeclaredConstructors(Unknown Source)
    org.springframework.beans.factory.annotation.Autow iredAnnotationBeanPostProcessor.determineCandidate Constructors(AutowiredAnnotationBeanPostProcessor. java:228)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.determineConstructorsFr omBeanPostProcessors(AbstractAutowireCapableBeanFa ctory.java:911)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:884)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:479)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:450)
    org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 90)
    org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:287 )
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:189)
    org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:562)
    org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:871)
    org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:423)
    org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 43)
    org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:4 59)
    org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:340 )
    org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:307)
    org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:127)
    javax.servlet.GenericServlet.init(GenericServlet.j ava:160)
    org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:929)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:407)
    org.apache.coyote.http11.AbstractHttp11Processor.p rocess(AbstractHttp11Processor.java:1002)
    org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(AbstractProtocol.java:585)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:312)
    java.util.concurrent.ThreadPoolExecutor$Worker.run Task(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
    java.lang.Thread.run(Unknown Source)


    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.32 logs.


    --------------------------------------------------------------------------------

    Apache Tomcat/7.0.32
    Last edited by antohoho; Oct 27th, 2012, 07:11 PM.

    Comment


    • #3
      totally lost

      added next files

      commons-beanutils-1.8.0.jar
      commons-digester-2.0.jar
      slf4j-api-1.5.8.jar

      See error:

      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be successfully initialized. See also http://www.slf4j.org/codes.html#unsuccessfulInit


      then - added this jcl-over-slf4j-1.5.8 and see 404 erroe

      http://tiles.apache.org/2.2/framewor...g_started.html


      Please some help I am totally lost




      I changed tiles to 2.2.2 version

      Comment


      • #4
        found problem
        I had to include - log4j-1.2.17.jar, slf4j-log4j12-1.7.2.jar
        and get rid of - jcl-over-slf4j-1.5.8

        now working fine.. thanks for listening me all this time

        Comment

        Working...
        X