Spring 4 с тайлами 3 Ошибка NoClassDefFoundError: org.apache.tiles.request.ApplicationContext - PullRequest
0 голосов
/ 18 сентября 2018

Я использую Spring Framework версии 4.0.6 и тайлы 3.0.1

Мой dispatcher-servlet.xml:

    <?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:mvc="http://www.springframework.org/schema/mvc"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:c="http://java.sun.com/jsp/jstl/core"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/security 
       http://www.springframework.org/schema/security/spring-security-3.2.xsd
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/util 
       http://www.springframework.org/schema/util/spring-util-4.0.xsd
       http://www.springframework.org/schema/mvc 
       http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

    <context:component-scan base-package="com.leonardo.*"/>

    <mvc:annotation-driven/> 
    <mvc:resources mapping="/css/**" location="/WEB-INF/css/" />
    <mvc:resources mapping="/img/**" location="/WEB-INF/img/" />
    <mvc:resources mapping="/js/**" location="/WEB-INF/js/" />
    <mvc:resources mapping="/fonts/**" location="/WEB-INF/fonts/" />

    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
        <property name="definitions">
        <list>
            <value>/WEB-INF/conf/tiles-definitions.xml</value>
        </list>
        </property>
    </bean>

</beans>

Мои тайлы.xml

    <?xml version="1.0" encoding="UTF-8"?>
     <!DOCTYPE tiles-definitions PUBLIC  
        "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"  
        "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
     <tiles-definitions>
      <definition name="DefaultTemplate" 
              template="/WEB-INF/views/returnP.jsp">
        <put-attribute name="title" value="" />
        <put-attribute name="header" value="/WEB-INF/views/header.jsp" />
        <put-attribute name="body" value="" />
        <put-attribute name="sidebar" value="/WEB-INF/views/sidebar.jsp" />
    </definition>

 <definition name="Template" extends="DefaultTemplate">
        <put-attribute name="title" value="Home" />
        <put-attribute name="header" value="/WEB-INF/views/header.jsp" />
        <put-attribute name="body" value="/WEB-INF/views/body.jsp" />
        <put-attribute name="sidebar" value="/WEB-INF/views/sidebar.jsp" />
    </definition>
</tiles-definitions>

Мой defautTemplate:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
    language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
    <html>
         <head>
            <title>returnP</title>
            <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
         </head>
         <body>
           <h1>${cf}</h1>
            <div class="container"
                style="border: #C1C1C1 solid 1px; border-radius: 10px;"><!-- Header -->
            <tiles:insertAttribute name="header" /> <!-- Menu Page -->
            <div class="span-5  border"
                style="height: 400px; background-color: #FCFCFC;">
        <!-- Body Page -->
            <div class="span-19 last">
                <tiles:insertAttribute name="body" />
            </div>
                <!-- Footer Page --> 
                <tiles:insertAttribute name="sidebar" />
            </div>
        </body>
    </html>

Мой контроллер:

    @Autowired ActionVerificaLogon actionVerificaLogon;

    @RequestMapping(value = { "/", "/index",})
    public ModelAndView index(HttpServletRequest request) {
        logger.info("############## START ##############");
        ModelAndView mv = new ModelAndView();
        mv.setViewName("index");

        return mv;
    }



    @RequestMapping(value = "/vericaLogon", method = RequestMethod.POST)
    public @ResponseBody ModelAndView vericaLogon(HttpServletRequest request, HttpServletResponse response, ModelMap model){
        logger.info("########################### START ###########################");   
        ModelAndView mv = new ModelAndView();
        String ret = null;
        try {

            FormUser730 formUser730 = actionVerificaLogon.execute(request, response);

            logger.info("formUser730 -> " + formUser730.getCOD_FIS());
            model.addAttribute("cf", formUser730.getCOD_FIS());
            mv.setViewName("Template");         
        }catch(Exception e) {
            logger.error("Errore [Esecuzione Ricerca]",e);
            return mv;
        }
        logger.info("########################### STOP ###########################");    

        return mv;                                    
    }

У меня есть импортированная tile-extras.jar версия 3.01.

И у меня есть эта ошибка:

    18/09/18 20.27.36:907 CEST] 00000040 ContextLoader E org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org.apache.tiles.request.servlet.ServletApplicationContext
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at .springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)

Помогите мне, пожалуйста ..........

1 Ответ

0 голосов
/ 19 сентября 2018

Похоже, у вас не все банки Tiles развернуты с вашим приложением.Глядя на мою текущую копию Tiles 3.0.7, похоже, что она в jar tiles-request-servlet-1.0.6.jar.

...