当前位置: 首页 > article >正文

tiles-api-2.0.4 升级tiles3.0.8遇到的问题

首先更改web.xml,以下是我项目完整的web.xml (struts2.5.30+tiles3.0.8)

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee;http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0">
  <display-name>项目名字</display-name>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:applicationContext.xml</param-value>
  </context-param>
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
 <!--   <context-param>   需要注释 ---因为升级后的tiles不需要指定配置文件,如果路径正确(/WEB-INF/tiles.xml),页面会自动找到
    <param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
    <param-name> org.apache.tiles.definition.DefinitionsFactory.DEFINITIONS_CONFIG</param-name>struts2以上需要升级为这个
    <param-value>/WEB-INF/tiles.xml</param-value>
  </context-param> -->
  
  <listener><!-- tiles监听器,默认配置文件在/WEB-INF/tiles*.xml-->
    <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
</listener>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
  </listener>
  <listener>
    <listener-class>com.我项目中自定义的监听器</listener-class>
  </listener>
  <welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
  </welcome-file-list>
  <session-config>
    <session-timeout>120</session-timeout>
  </session-config>
  <error-page>
    <error-code>500</error-code>
    <location>/commons/error.jsp</location>
  </error-page>
  <error-page>
    <error-code>404</error-code>
    <location>/commons/404.jsp</location>
  </error-page>
  <error-page>
    <error-code>403</error-code>
    <location>/commons/403.jsp</location>
  </error-page>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>globalMessages</param-value>
  </context-param>
</web-app>

以下是出现的问题:

1.缺少tiles-request-api3.0.8.jar ,报错如下:

  Caused by: java.lang.ClassNotFoundException: org.apache.tiles.request.ApplicationContext
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1187)
    

2. 缺少tiles-extras3.0.8.jar ,报错如下:

严重: 配置应用程序监听器[org.apache.tiles.extras.complete.CompleteAutoloadTilesListener]错误
java.lang.ClassNotFoundException: org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1187)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:539)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:520)

3. 添加完tiles-extras之后配置监听器 :

 <listener>
<listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
</listener>

之后就会报错,此时就需要添加: tiles-servlet3.0.8.jar 解决:

java.lang.ClassNotFoundException: org.apache.tiles.web.startup.AbstractTilesInitializer找不到,

4. 缺少slf4j-api-1.7.26.jar ,报错:

Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1187)

5. 暂时未解决:

严重: 例外情况发送上下文删除事件[org.apache.tiles.extras.complete.CompleteAutoloadTilesListener],以便列表实例
java.lang.NullPointerException
at org.apache.tiles.access.TilesAccess.setContainer(TilesAccess.java:90)
at org.apache.tiles.startup.AbstractTilesInitializer.destroy(AbstractTilesInitializer.java:70)
at org.apache.tiles.web.startup.AbstractTilesListener.contextDestroyed(AbstractTilesListener.java:63)

5.5. 添加 slf4j-api-1.7.26.jar 解决:

Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1187)

6. 添加tiles-request-servlet-wildcard-1.0.7.jar解决 :

java.lang.NoClassDefFoundError: org/apache/tiles/request/servlet/wildcard/WildcardServletApplicationContext
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesInitializer.createTilesApplicationContext(CompleteAutoloadTilesInitializer.java:46)
    at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:61)
    at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:53)

7. 添加mvel2-2.4.15.Final.jar解决 :

    严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.apache.tiles.extras.complete.CompleteAutoloadTilesListener]
java.lang.NoClassDefFoundError: org/mvel2/integration/VariableResolverFactory
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesInitializer.createContainerFactory(CompleteAutoloadTilesInitializer.java:54)
    at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:11

8. 添加tiles-ognl-3.0.8.jar解决 :

    严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.apache.tiles.extras.complete.CompleteAutoloadTilesListener]
java.lang.NoClassDefFoundError: org/apache/tiles/ognl/NestedObjectExtractor
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesInitializer.createContainerFactory(CompleteAutoloadTilesInitializer.java:54)
    at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:113)

9. 添加tiles-compat-3.0.8.jar解决 :

java.lang.NoClassDefFoundError: org/apache/tiles/compat/definition/digester/CompatibilityDigesterDefinitionsReader
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory.createDefinitionsReader(CompleteAutoloadTilesContainerFactory.java:229)
    at org.apache.tiles.factory.BasicTilesContainerFactory.createLocaleDefinitionDao(BasicTilesContainerFactory.java:181)
    at org.apache.tiles.factory.BasicTilesContainerFactory.createDefinitionsFactory(BasicTilesContainerFactory.java:137)

10. 添加tiles-el-3.0.8.jar解决 :

严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.apache.tiles.extras.complete.CompleteAutoloadTilesListener]
java.lang.NoClassDefFoundError: org/apache/tiles/el/ELAttributeEvaluator

11. 添加tiles-mvel-3.0.8.jar解决 :

java.lang.NoClassDefFoundError: org/apache/tiles/mvel/ScopeVariableResolverFactory
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory.createMVELEvaluator(CompleteAutoloadTilesContainerFactory.java:267)
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory.createAttributeEvaluatorFactory(CompleteAutoloadTilesContainerFactory.java:184)

12. 添加tiles-request-freemarker-1.0.7.jar解决 :

严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.apache.tiles.extras.complete.CompleteAutoloadTilesListener]
java.lang.NoClassDefFoundError: org/apache/tiles/request/freemarker/render/FreemarkerRendererBuilder
at org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory.registerAttributeRenderers(CompleteAutoloadTilesContainerFactory.java:140)
at org.apache.tiles.factory.BasicTilesContainerFactory.createRendererFactory(BasicTilesContainerFactory.java:270)
at org.apache.tiles.factory.BasicTilesContainerFactory.createContainer(BasicTilesContainerFactory.java:93)

13. 添加tiles-freemarker-3.0.8.jar 解决 :

java.lang.NoClassDefFoundError: org/apache/tiles/freemarker/TilesSharedVariableFactory
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory.registerAttributeRenderers(CompleteAutoloadTilesContainerFactory.java:140)
    at org.apache.tiles.factory.BasicTilesContainerFactory.createRendererFactory(BasicTilesContainerFactory.java:270)

14. 添加tiles-autotag-core-1.2.jar ,tiles-autotag-core-runtime-1.2.jar解决 :

严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.apache.tiles.extras.complete.CompleteAutoloadTilesListener]
java.lang.NoClassDefFoundError: org/apache/tiles/autotag/core/runtime/AutotagRuntime
    at org.apache.tiles.freemarker.template.TilesFMModelRepository.<init>(TilesFMModelRepository.java:69)

15. 添加 tiles-request-velocity-1.0.7.jar解决 :

严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.apache.tiles.extras.complete.CompleteAutoloadTilesListener]
java.lang.NoClassDefFoundError: org/apache/tiles/request/velocity/render/VelocityRendererBuilder
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory.registerAttributeRenderers(CompleteAutoloadTilesContainerFactory.java:153)
    at org.apache.tiles.factory.BasicTilesContainerFactory.createRendererFactory(BasicTilesContainerFactory.java:270)

16. 添加velocity-tools-2.0.jar (注意一定不要下错成 velocity-tools-view-1.4.jar)解决 :

java.lang.NoClassDefFoundError: org/apache/velocity/tools/view/JeeConfig
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory.registerAttributeRenderers(CompleteAutoloadTilesContainerFactory.java:153)
    at org.apache.tiles.factory.BasicTilesContainerFactory.createRendererFactory(BasicTilesContainerFactory.java:270)

17. 添加velocity-1.7.jar解决 :

java.lang.NoClassDefFoundError: org/apache/velocity/context/Context
    at java.lang.ClassLoader.defineClass1(Native Method)

18. 添加commons-lang-2.6.jar解决 :

java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
    at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:161)

19. 添加tiles-request-mustache-1.0.7.jar解决 :

    java.lang.NoClassDefFoundError: org/apache/tiles/request/mustache/MustacheRenderer
    at org.apache.tiles.extras.complete.CompleteAutoloadTilesContainerFactory.registerAttributeRenderers(CompleteAutoloadTilesContainerFactory.java:157)
    at org.apache.tiles.factory.BasicTilesContainerFactory.createRendererFactory(BasicTilesContainerFactory.java:270)

20. 添加compiler-0.9.10.jar (这个最难找,在 https://mvnrepository.com 中搜索com.github.spullara.mustache.java才下载到的) 解决:

java.lang.NoClassDefFoundError: com/github/mustachejava/MustacheFactory 

因为这个难找,因此把maven依赖记录下来
<dependency>
    <groupId>com.github.spullara.mustache.java</groupId>
    <artifactId>compiler</artifactId>
    <version>0.9.10</version>
</dependency>

21. taglib标签升级后的问题:

严重: 在路径为/WIFS的上下文中,Servlet[jsp]的Servlet.service()引发了具有根本原因的异常在 [34] 行处理 [login.jsp] 时发生异常

 %>

 <div>
<tiles:insertDefinition name="login"></tiles:insertDefinition> ------当前项目中登录页面使用了tiles:insertDefinition标签,因此可以判断升级之后tiles-jsp.tld这个文件也需要把最新的jar包中的这个文件更新,否则无法使用
 </div>

Stacktrace:
java.lang.ClassCastException: org.apache.tiles.jsp.taglib.InsertDefinitionTag cannot be cast to javax.servlet.jsp.tagext.Tag

解决办法:

打开tiles-jsp-3.0.8.jar 在/META-INF/tld/中打开tiles-jsp.tld与tiles-extras-jsp.tld ,在项目中WEB-INF(web.xml根目录)下新建这两个文件,然后把jar包中的这两个文件内容复制过来(如果之前已经有了这两个tld那就把内容覆盖)

重 点:

反正也就是报错信息 ClassNotFoundException: org.apache.tiles.xxx  
那就去https://mvnrepository.com/  中搜,tiles-xxx,下载统一版本的jar即可,
最终我新增或更改的jar包如下:
struts2-core-2.5.30.jar
struts2-dojo-plugin-2.3.37.jar
struts2-spring-plugin-2.5.30.jar
struts2-tiles-plugin-2.5.30.jar
tiles-api-3.0.8.jar
tiles-autotag-core-1.2.jar
tiles-autotag-core-runtime-1.2.jar
tiles-compat-3.0.8.jar
tiles-core-3.0.8.jar
tiles-el-3.0.8.jar
tiles-extras-3.0.8.jar
tiles-freemarker-3.0.8.jar
tiles-jsp-3.0.8.jar
tiles-mvel-3.0.8.jar
tiles-ognl-3.0.8.jar
tiles-request-api-1.0.7.jar
tiles-request-freemarker-1.0.7.jar
tiles-request-jsp-1.0.7.jar
tiles-request-mustache-1.0.7.jar
tiles-request-servlet-1.0.7.jar
tiles-request-servlet-wildcard-1.0.7.jar
tiles-request-velocity-1.0.7.jar
tiles-servlet-3.0.8.jar
tiles-template-3.0.8.jar
velocity-1.7.jar
velocity-tools-2.0.jar
slf4j-api-1.7.26.jar
commons-lang-2.6.jar
javassist-3.28.0-GA.jar
mvel2-2.4.15.Final.jar
ognl-3.1.27.jar

以下三个是我升级之前使用到的
tiles-api-2.0.4.jar
tiles-core-2.0.4.jar
tiles-jsp-2.0.4.jar

-----------------------完成以上操作最终启动项目访问页面 -----------成功


http://www.kler.cn/a/2685.html

相关文章:

  • 【STM32+QT项目】基于STM32与QT的智慧粮仓环境监测与管理系统设计(完整工程资料源码)
  • 左神算法基础巩固--3
  • docker minio镜像arm64架构
  • LabVIEW调用不定长数组 DLL数组
  • QT 端口扫描附加功能实现 端口扫描5
  • Django:构建高效Web应用的强大框架
  • 三十七、实战演练之接口自动化平台的文件上传
  • MyBatisPlus的Wrapper使用示例
  • 在linux上安装配置nodejs工具,设置环境变量,设置npm国内镜像源,提高下载速度。
  • 深度学习应用技巧4-模型融合:投票法、加权平均法、集成模型法
  • cjson文件格式介绍
  • 音视频开发—MediaCodec 解码H264/H265码流视频
  • SpringBoot 结合RabbitMQ与Redis实现商品的并发下单【SpringBoot系列12】
  • Linux下的指令(常用的指令,以及案例展示)
  • QEMU启动ARM32 Linux内核
  • Thread类的基本用法
  • linux信号理解
  • spring5(四):IOC 操作 Bean 管理(基于注解方式)
  • SQL优化13连问,收藏好!
  • Docker常规安装简介
  • windows微服务部署
  • 天猫2月咖啡行业数据分析(咖啡品牌销量排行)
  • 面试--每日一经
  • ThinkPHP02:路由
  • STM32MP157-QT-串口调试助手设计
  • python常见算法(chatgpt算法实现)