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

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



  项目名字
  
    org.springframework.web.context.ContextLoaderListener
  
  
    contextConfigLocation
    classpath*:applicationContext.xml
  
  
    struts2
    org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
  
  
    struts2
    /*
  
 
  
  
    org.apache.tiles.extras.complete.CompleteAutoloadTilesListener

  
    org.springframework.web.context.ContextLoaderListener
  
  
    org.springframework.web.util.IntrospectorCleanupListener
  
  
    com.我项目中自定义的监听器
  
  
    login.jsp
  
  
    120
  
  
    500
    /commons/error.jsp
  
  
    404
    /commons/404.jsp
  
  
    403
    /commons/403.jsp
  
  
    javax.servlet.jsp.jstl.fmt.localizationContext
    globalMessages
  

以下是出现的问题:

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之后配置监听器 :

 
org.apache.tiles.extras.complete.CompleteAutoloadTilesListener

之后就会报错,此时就需要添加: 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.(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依赖记录下来

    com.github.spullara.mustache.java
    compiler
    0.9.10

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

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

 %>

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

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

你可能感兴趣的:(java,tiles,升级)