Announcement Announcement Module
Collapse
No announcement yet.
NoSuchDefinition tiles with multiple DispatcherServlet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NoSuchDefinition tiles with multiple DispatcherServlet

    hi guys i have a problem with tiles definition, i explain my webapp, this two DispatcherServlet, one for servlet and tiles of search and other of admin
    This is web.xml with two DispatcherServlet
    Code:
    <servlet>
    		<servlet-name>Search</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	</servlet>
    	
    	<servlet>
    		<servlet-name>Admin</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	</servlet>
    <servlet-mapping>
    		<servlet-name>Search</servlet-name>
    		<url-pattern>/search/*</url-pattern>
    	</servlet-mapping>
    	
    	<servlet-mapping>
    		<servlet-name>Admin</servlet-name>
    		<url-pattern>/admin/*</url-pattern>
    	</servlet-mapping>
    There are the xml servlet

    Search-servlet.xml
    Code:
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    		<property name="definitions">
    			<list>
    				<value>/WEB-INF/config/search-tiles.xml</value>
    				
    			</list>
    		</property>
    	</bean>
    	
    	<!-- ViewResolver -->
    	<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    		<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
    	</bean>
    admin-servlet.xml
    Code:
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    		<property name="definitions">
    			<list>
    				<value>/WEB-INF/config/admin-tiles.xml</value>
    				
    			</list>
    		</property>
    	</bean>
    	
    	<!-- ViewResolver -->
    	<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    		<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
    	</bean>
    tiles-search.xml
    Code:
    	 <definition name="search">
        		<put-attribute name="central" value="/WEB-INF/jsp/search.jsp"/>	
       	 </definition>
    tiles-admin.xml
    Code:
    	 <definition name="admin">
        		<put-attribute name="central" value="/WEB-INF/jsp/admin.jsp"/>	
       	 </definition>
    The problem is when user1 enter in application and is in search context, and user2 enter in application and is in admin context, now the user1 if refresh your page, being always in search context, this error occurs

    DEBUG org.apache.tiles.impl.BasicTilesContainer - Render request recieved for definition 'search'
    WARN org.apache.tiles.impl.BasicTilesContainer - Unable to find the definition 'search'
    DEBUG org.springframework.web.servlet.DispatcherServlet - Could not complete request
    ERROR org.apache.tiles.definition.NoSuchDefinitionExcept ion: search

    I try include in admin-servlet.xml this definition /WEB-INF/config/search.xml and the error disappears. I realized this, user1 enter in search, user2 enter in admin, now user1 use the tiles which are in admin-servlet.xml instead in Search-servlet.xml. However if I declare the tiles.xml in a single file, everything works without error, but i want separate statement tiles-xml
    someone would know how to solve the problem? thanks for the help
    Last edited by texas799; Feb 21st, 2012, 04:16 AM.

  • #2
    You can still have multiple tiles.xml files and a single tiles configurer. Definitions can be (it is recommended even) if different definition files. The problem with tiles is that it uses some singletons to store state so having multiple configurers isn't possible.

    Comment

    Working...
    X