web.xml修改,我原项目跟他一样,所以不用改
修改前
context
org.springframework.web.context.ContextLoaderServlet
1
修改后
org.springframework.web.context.ContextLoaderListener
命名空间修改前
命名空间修改后
spring 4.x 去掉了 dependency-check
引用bean bean=代替了local=
我的项目没找到dependency-check,所以没有替代为local
我引用bean如下
【错误处理1】
1、信息: 至少有一个JAR被扫描用于TLD但尚未包含TLD。 为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。 在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。
9月 23, 2023 11:44:02 上午 org.apache.catalina.core.StandardContext listenerStart
严重: 配置应用程序监听器[org.springframework.web.context.ContextLoaderListener]错误
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
发现spring4的jar包没有发布到TomCat里面,所以直接把jar包复制到lib路径
【错误处理2】
信息: 至少有一个JAR被扫描用于TLD但尚未包含TLD。 为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。 在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。
9月 23, 2023 11:48:52 上午 org.apache.catalina.core.StandardContext filterStart
严重: 启动过滤器异常[struts2]
java.lang.ClassCastException: class org.apache.struts2.dispatcher.FilterDispatcher cannot be cast to class jakarta.servlet.Filter (org.apache.struts2.dispatcher.FilterDispatcher is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @5b057c8c; jakarta.servlet.Filter is in unnamed module of loader java.net.URLClassLoader @5b464ce8)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:243)
这个是web.xmll配置的struts2拦截器
在struts2.1版本之前,所使用的核心过滤器类是 org.apache.struts2.dispatcher.FilterDispatcher,
从struts2.1版本之后,已经不推荐使用,而是使用org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter类。
当struts2.5之后的版本时,推荐将类完全名称中的ng去掉,即使用org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter类。
可是我的项目是struts2-2.1.6,难道要一起升级一下吗?
百度了一下jakarta
原来TomCat10需要使用到 Jakarta 6.0 的版本,而我也刚好把TomCat升级为TomCat10;
而spring4.3 和struts2.1 项目使用的 javax 冲突了
理论上来讲,Java EE 8 (2017 年 8 月 31 日)已经结束了,之后就没有 Java EE 了。原文是这么说的 Oracle waves good-bye to Java Enterprise Edition, as the Eclipse Foundation takes over Java EE under a new name, Jakarta, and without the “Java” trademark 。所以以后基于 Java EE 的规范,比如 Servlet 等都需要做不兼容的升级
你可以使用工具来将原来的 javax 包名的项目转换到新的项目下:
GitHub 在这里: https://github.com/apache/tomcat-jakartaee-migration
或者这里: https://tomcat.apache.org/download-migration.cgi
参考资料:
https://www.cnblogs.com/cyq1162/p/16627619.html
https://www.nuomiphp.com/t/62f726597ac6e30c717413b1.html
对于这个错误,我选择不动,降级TomCat为8.5,因为我主要目的是升级spring就好了。
【错误处理3】
ERROR - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘txAdvice1’: Cannot resolve reference to bean ‘transactionManager1’ while setting bean property ‘transactionManager’; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name ‘transactionManager1’ defined in class path resource [applicationContext-db1.xml]: Cannot resolve reference to bean ‘sessionFactory1’ while setting bean property ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name ‘sessionFactory1’: Failed to introspect bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/RegionFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
看到这个applicationContext-db1.xml,就想到我这两个文件的标头还没改,于是也一起改了,参考applicationContext-db.xml
改完运行还是报这个错误
研究了一下这个文件,没看出啥
dataSource1–》sessionFactory1–》transactionManager1–》txAdvice1
最后再仔细看了那个错误,说是缺少org/hibernate/cache/RegionFactory
百度了一下 hibernate3.0版本压根就没有这个org.hibernate.cache.RegionFactory类,我看了一下我的是hibernate-3.2.6
因此最后把hibernate3.2.6版本换成4.2版本,再运行,就出现了下面的错误
【错误处理4】
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘txAdvice1’: Cannot resolve reference to bean ‘transactionManager1’ while setting bean property ‘transactionManager’; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name ‘transactionManager1’ defined in class path resource [applicationContext-db1.xml]: Cannot resolve reference to bean ‘sessionFactory1’ while setting bean property ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name ‘sessionFactory1’: Failed to introspect bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
一大段英文,看到最后就是缺少这个Lorg/hibernate/engine/FilterDefinition
这是我改了Hibernate的版本为4.2,所以需要修改spring配置文具,上一步没有修改导致的,我改成4
改好之后,又出现以下问题
【错误处理5】
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘txAdvice1’: Cannot resolve reference to bean ‘transactionManager1’ while setting bean property ‘transactionManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘transactionManager1’ defined in class path resource [applicationContext-db1.xml]: Cannot resolve reference to bean ‘sessionFactory1’ while setting bean property ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory1’ defined in class path resource [applicationContext-db1.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/jboss/logging/BasicLogger
这次不管,直接看最后,缺少org/jboss/logging/BasicLogger
原因:缺少jboss-logging的jar包
解决方法:添加jboss-logging.jar到lib下
这个挺奇怪的,之前怎么就不会缺少,换了Hibernate4就缺少了。
【错误处理6】
上面加人jar之后,重启又提示这个错误
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘txAdvice1’: Cannot resolve reference to bean ‘transactionManager1’ while setting bean property ‘transactionManager’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘transactionManager1’ defined in class path resource [applicationContext-db1.xml]: Cannot resolve reference to bean ‘sessionFactory1’ while setting bean property ‘sessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory1’ defined in class path resource [applicationContext-db1.xml]: Invocation of init method failed;
nested exception is java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.search.hcore.impl.HibernateSearchIntegrator could not be instantiated
看最后面instantiated(实例化),org.hibernate.search.hcore.impl.HibernateSearchIntegrator 没法实例化
这个不知道哪里导致无法实例化
只能拉下去看其它错误,看到这句
Caused by: java.lang.ClassNotFoundException: org.jboss.logging.DelegatingBasicLogger
难道是我上面加的jboss-logging.jar包不对?重新下载了个jboss-logging-3.3.2.Final
重新运行,出现其它错误了
【错误处理7】
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/index/CorruptIndexException
Lucene是apache软件基金会 jakarta项目组的一个子项目,是一个开放源代码的全文检索引擎工具包,但它不是一个完整的全文检索引擎,而是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎,部分文本分析引擎(英文与德文两种西方语言)。
于是加入了lucene4.0常用jar包
重新运行,又有错误了
【错误处理8】
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory1’ defined in class path resource [applicationContext-db1.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: class org.hibernate.search.util.impl.DelegateNamedAnalyzer overrides final method org.apache.lucene.analysis.Analyzer.tokenStream(Ljava/lang/String;Ljava/io/Reader;)Lorg/apache/lucene/analysis/TokenStream;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
… 34 more
Caused by: java.lang.IncompatibleClassChangeError: class org.hibernate.search.util.impl.DelegateNamedAnalyzer overrides final method org.apache.lucene.analysis.Analyzer.tokenStream(Ljava/lang/String;Ljava/io/Reader;)Lorg/apache/lucene/analysis/TokenStream;
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
上面引入的lucene4.0版本不对,重新换个lucene-analyzers-3.5.0,换了lucene-core-7.0.1.jar,还是不行,应该是Lucene版本对不上,头痛不想搞了,还不如重新建个项目,把代码搬过去得了。哭死o(╥﹏╥)o
【错误处理9】
Hibernate 3.5+之后取消掉了 Hibernate.STRING
取而代之的就是StandardBasicTypes
SQLQuery q = this.session.createSQLQuery(sql);
q.addScalar(“isbn”, StandardBasicTypes.STRING);
q.addScalar(“bname”, StandardBasicTypes.STRING);
q.addScalar(“pubdate”, StandardBasicTypes.DATE);
q.addScalar(“press”, StandardBasicTypes.STRING);
q.addScalar(“author”, StandardBasicTypes.STRING);
q.addScalar(“price”, StandardBasicTypes.DOUBLE);
q.addScalar(“bkcount”, StandardBasicTypes.INTEGER);
q.addScalar(“descb”, StandardBasicTypes.STRING);
————————————————
版权声明:本文为CSDN博主「蜡基ZQ」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_34239028/article/details/81293441
休息了几个小时,心有不甘,还是继续折腾旧项目
这一次我觉得我的项目lib太乱了,直接全部删除,然后导入spring的包+Hibernate+Struts;然后处理报错的源码,缺什么包就导入什么包,直到没出现红线提醒。全部包如下:
1、spring 全是spring开头
2、Hibernate 全是Hibernate开头
3、Struts一大堆包
下载官网 https://struts.apache.org/download.cgi
4、json3个版本
阿里云的:fastjson-1.1.22
另一个:json-lib-2.4-jdk15
第3个:flexjson-2.0
5、jasperreports打印小票用的
jasperreports-3.7.4
6、阿里云群发短信
aliyun-java-sdk-core-3.3.1
aliyun-java-sdk-dysmsapi-1.0.0
7、dom4j【读取sql.xml用的】
dom4j-1.6.1
8、【读取加密的配置文件用的 在SecurityDataSource.java里面用到】
proxool-0.9.1
proxool-cglib
9、【导出Excel】
jxl
10、【汉语转拼音,CommonChinese里面用到】
pinyin4j
11、数据库驱动包
然后尝试TomCat运行,继续处理出现的错误
【处理错误1】
严重: 子容器启动失败
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: 无法启动组件[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/XXYEY]]
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:891)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:793)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)
at org.apache.catalina.core.ContainerBase S t a r t C h i l d . c a l l ( C o n t a i n e r B a s e . j a v a : 1364 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . C o n t a i n e r B a s e StartChild.call(ContainerBase.java:1364) at org.apache.catalina.core.ContainerBase StartChild.call(ContainerBase.java:1364)atorg.apache.catalina.core.ContainerBaseStartChild.call(ContainerBase.java:1354)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.apache.catalina.LifecycleException: 无法启动组件[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/XXYEY]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:419)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:186)
… 6 more
Caused by: java.lang.IllegalArgumentException: 找到多个名为[spring_web]的片段。这是不合法的相对排序。有关详细信息,请参阅Servlet规范的第8.2.2 2c节。考虑使用绝对排序。
at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2219)
就想到修改web.xml的拦截器,因为我顺便把Struts的包换为 Struts2.5.32
这个是web.xmll配置的struts2拦截器
当struts2.5之后的版本时,推荐将类完全名称中的ng去掉,即使用org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter类。
重试还是有错误,然后仔细看报的错,找到多个名为[spring_web]的片段,原来是我导入的spring包重复了
我导入的是spring4.3.13 ,然后官网下载的Struts包含了spring4.3.26才导致的这个错误;于是把我自己的spring包全删掉,只留Struts里面的spring包,错误消失,又出现新错误
【错误处理2】
这个是我把jdk的版本选太高了,我选了jdk18;切换jdk7就可以了
【错误处理3】
这个是Struts下载包含的spring包缺包,把它的包删了,用我自己下载的spring包
【错误处理4】
Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3434)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2536)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:247)
… 50 more
异常原因:缺少aspectjweaver.jar这个包,该包是spring集成AspectJ LTW织入器所需包;
解决方案:在工程中加入 aspectjweaver.jar 包。
【错误处理5】
Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:488)
at java.base/java.lang.Class.forName(Class.java:467)
at org.jboss.logging.Logger$1.run(Logger.java:2554)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2529)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2516)
at org.hibernate.cfg.Configuration.(Configuration.java:176)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:343)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
… 41 more
Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1420)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1228)
… 52 more
不知道有什么用,添加jta.jar即可 Jta
【错误处理6】
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/index/CorruptIndexException
又回到这个问题了,lucene
【错误处理7】
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
参考https://blog.csdn.net/pipizhen_/article/details/108300039
JAXB API是java EE 的API,因此在java SE 9.0 中不再包含这个 Jar 包。java 9 中引入了模块的概念,默认情况下,Java SE中将不再包含java EE 的Jar包 。而在 java 6/7 / 8 时关于这个API 都是捆绑在一起的。
【错误处理8】
Caused by: java.lang.ClassNotFoundException: com.fasterxml.classmate.Filter
引入
com.fasterxml.jackson.databind.jar
classmate-62.jar
【错误处理9】
Caused by: java.lang.IncompatibleClassChangeError: class org.hibernate.search.util.impl.DelegateNamedAnalyzer overrides final method org.apache.lucene.analysis.Analyzer.tokenStream(Ljava/lang/String;Ljava/io/Reader;)Lorg/apache/lucene/analysis/TokenStream;
又是回到这个问题TokenStream
【Lucene】官网https://archive.apache.org/dist/lucene/java/
把我导入的Lucene7替换掉,换成版本lucene3.2.0.终于摆脱这个错误了
参考http://blog.haoji.me/an-error-about-lucene-and-ikanalyzer.html
【错误处理10】
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console…
官网下载 https://logging.apache.org/log4j/2.x/download.html
包里面有很多个文件,只复制两个log4j-api-2.12.4 log4j-core-2.12.4
【错误处理11】
ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property ‘log4j2.debug’ to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
这个是说没有Log4j 2的配置文件,将使用默认配置。还有如果要debug模式,见那个网站;应该可以不用管这个错误
【错误处理12】
ERROR org.apache.struts2.dispatcher.Dispatcher - Dispatcher initialization failed
com.opensymphony.xwork2.config.ConfigurationException: Unable to load configuration.
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69) ~[struts2-core-2.5.32.jar:2.5.32]
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:970) ~[struts2-core-2.5.32.jar:2.5.32]
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:463) ~[struts2-core-2.5.32.jar:2.5.32]
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:496) [struts2-core-2.5.32.jar:2.5.32]
at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:73) [struts2-core-2.5.32.jar:2.5.32]
at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:61) [struts2-core-2.5.32.jar:2.5.32]
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:272) [catalina.jar:8.5.93]
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254) [catalina.jar:8.5.93]
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:100) [catalina.jar:8.5.93]
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4290) [catalina.jar:8.5.93]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4925) [catalina.jar:8.5.93]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171) [catalina.jar:8.5.93]
at org.apache.catalina.core.ContainerBase S t a r t C h i l d . c a l l ( C o n t a i n e r B a s e . j a v a : 1364 ) [ c a t a l i n a . j a r : 8.5.93 ] a t o r g . a p a c h e . c a t a l i n a . c o r e . C o n t a i n e r B a s e StartChild.call(ContainerBase.java:1364) [catalina.jar:8.5.93] at org.apache.catalina.core.ContainerBase StartChild.call(ContainerBase.java:1364)[catalina.jar:8.5.93]atorg.apache.catalina.core.ContainerBaseStartChild.call(ContainerBase.java:1354) [catalina.jar:8.5.93]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
at java.lang.Thread.run(Thread.java:833) [?:?]
终于处理到Struts2的错误了
这里看不出是什么问题导致拦截器初始化失败,就照着错误信息往下找,找到这句话
Causedby:java.lang.ClassNotFoundException:org.apache.struts2.views.gxp.inject.InjectedObjectContainer
又是缺少类,找到这篇文章
https://blog.csdn.net/iteye_6551/article/details/82550404
删掉struts2-gxp-plugin-2.3.15.3.jar包,重新启动TomCat
【错误处理13】
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalStateException: Cannot build bean, bundle resource loader is null
at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:477)
at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:514)
at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:567)
at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:512)
at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:50)
at com.opensymphony.xwork2.inject.ContainerBuilder 4. c r e a t e ( C o n t a i n e r B u i l d e r . j a v a : 159 ) . . . 62 m o r e C a u s e d b y : j a v a . l a n g . R u n t i m e E x c e p t i o n : j a v a . l a n g . R u n t i m e E x c e p t i o n : ∗ ∗ j a v a . l a n g . I l l e g a l S t a t e E x c e p t i o n : C a n n o t b u i l d b e a n , b u n d l e r e s o u r c e l o a d e r i s n u l l ∗ ∗ a t c o m . o p e n s y m p h o n y . x w o r k 2. i n j e c t . C o n t a i n e r I m p l 4.create(ContainerBuilder.java:159) ... 62 more Caused by: java.lang.RuntimeException: java.lang.RuntimeException: **java.lang.IllegalStateException: Cannot build bean, bundle resource loader is null** at com.opensymphony.xwork2.inject.ContainerImpl 4.create(ContainerBuilder.java:159)...62moreCausedby:java.lang.RuntimeException:java.lang.RuntimeException:∗∗java.lang.IllegalStateException:Cannotbuildbean,bundleresourceloaderisnull∗∗atcom.opensymphony.xwork2.inject.ContainerImplMethodInjector.inject(ContainerImpl.java:286)
at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:420)
at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:475)
… 67 more
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Cannot build bean, bundle resource loader is null
at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:161)
at com.opensymphony.xwork2.inject.Scope$2 1. c r e a t e ( S c o p e . j a v a : 53 ) a t c o m . o p e n s y m p h o n y . x w o r k 2. i n j e c t . C o n t a i n e r I m p l 1.create(Scope.java:53) at com.opensymphony.xwork2.inject.ContainerImpl 1.create(Scope.java:53)atcom.opensymphony.xwork2.inject.ContainerImplParameterInjector.inject(ContainerImpl.java:446)
at com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:460)
at com.opensymphony.xwork2.inject.ContainerImpl.access 000 ( C o n t a i n e r I m p l . j a v a : 33 ) a t c o m . o p e n s y m p h o n y . x w o r k 2. i n j e c t . C o n t a i n e r I m p l 000(ContainerImpl.java:33) at com.opensymphony.xwork2.inject.ContainerImpl 000(ContainerImpl.java:33)atcom.opensymphony.xwork2.inject.ContainerImplMethodInjector.inject(ContainerImpl.java:284)
… 69 more
头大,回想起上一个错误,不要引进不必要的Struts包,所以把多余的Struts包删了
【错误处理14】
严重: Couldn’t load class net.sourceforge.jtds.jdbc.Driver
java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1420)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1228)
引进jtds-1.2.4
【错误处理15】
1 [localhost-startStop-1] ERROR org.apache.struts2.convention.DefaultClassFinder - Unable to read class [com.base.data.MiniUIServ.action.LoadDataAction]
java.lang.IllegalArgumentException: Unsupported class file major version 62
at org.objectweb.asm.ClassReader.(ClassReader.java:196) ~[asm-7.3.1.jar:7.3.1]
at org.objectweb.asm.ClassReader.(ClassReader.java:177) ~[asm-7.3.1.jar:7.3.1]
at org.objectweb.asm.ClassReader.(ClassReader.java:163) ~[asm-7.3.1.jar:7.3.1]
at org.objectweb.asm.ClassReader.(ClassReader.java:284) ~[asm-7.3.1.jar:7.3.1]
at org.apache.struts2.convention.DefaultClassFinder.readClassDef(DefaultClassFinder.java:461) ~[struts2-convention-plugin-2.5.32.jar:2.5.32]
at org.apache.struts2.convention.DefaultClassFinder.access$200(DefaultClassFinder.java:52) ~[struts2-conv
终于错误里面出现我自己写的类了
这里看到Unsupported class file major version 62*,应该是java版本问题
我原先用的是jdk1.7;于是我就全部换成jdk1.8
【错误处理16】
换完jdk1.8后,我原先是用的tomcat8.5的,跑不动了,tomcat8.5的jdk也被我换成jdk1.8,直接跑不起来;
百度完才发现tomcat8.5只支持jdk1.7及以下
于是下载了一个Tomcat9,成功跑起来了
https://tomcat.apache.org/
【对于Tomcat 10】
对于tomcat10,还是有点不甘心,再测一下tomcat10,还是因为jakarta的问题跑不起来。按理说应该支持的呀,奇怪
官网:
https://www.oracle.com/cn/java/technologies/downloads/archive/
https://jdk.java.net/java-se-ri/11-MR2
把TomCat 10的jdk换成11,也还是报jakarta错误。算了,这里不折腾了,老实用TomCat9就好了
这里的jdk关系要理清
TomCat 10 至少需要选择Java SE 11,这样TomCat 10 才可以跑起来;
这样的TomCat10 支持 (jdk1.8及以前的项目,也支持Jakatra EE 9的项目)见上面两个图片
【Jakarta的由来】
Java是一种可以撰写跨平台应用软件的面向对象的程序设计语言。它分为三个版本:
Java SE(J2SE):标准版。基础中的基础,后面2个版本都依赖于它。当前最新版本是Java 17(LTS版本,将于2021年9月发布)
Java EE(J2EE):企业版。用于企业级大型应用开发,包含了Web、Security、Management等几十种标准技术
Java ME(J2ME):移动版。随着Android/iOS的流行,它已几乎销声匿迹
Oracle将 Java EE (Java SE还自己保留)交给开源组织,Eclipse基金会接手。但Oracle不允许开源组织使用Java名号,所以Jakarta EE名称于2018.02.26应运而生
【后续改Jakarta思路】
我现在项目就是Java EE 8;所以如果想改,可以直接改为Jakarta EE 9;然后把所有命名空间javax改为jakarta;版本号全部加1
这里先不改了,以后再改吧。
以下是用TomCat 9跑起来项目了,访问Action出现的错误
【错误处理1】
严重: Servlet[jsp]的Servlet.service()抛出异常
org.apache.jasper.JasperException: /WEB-INF/studentManage/p2023b/studentList.jsp (行.: [9], 列: [1]) 属性[id]无效为tag[url] 通过TLD
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:292)
因为我把Struts2.1升级为Struts2.5,所有jsp页面需要修改
就是jsp中strust相关标签的更改,要把id改为var;这下头晕了,应该有一两百个jsp页面。
【错误处理2】
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_05]
java.lang.ClassCastException: org.springframework.orm.hibernate4.SessionHolder cannot be cast to org.springframework.orm.hibernate3.SessionHolder
at org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:295)
at org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(SessionFactoryUtils.java:241)
at org.springframework.orm.hibernate3.HibernateTemplate.getSession(HibernateTemplate.java:462)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:398)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:342)
这是加载页面数据发生的错误,我加入了数据库的驱动包
看到hibernate3,因为我Hibernate升级为Hibernate4了,所以把dao层里面的Hibernate3全改为4
改完数据总算加载出来了。
明天再慢慢改jsp页面里面的id为var了
算是告一段落,折腾了一天,本来只想升级spring的,最后把Struts和Hibernate也一起升级了。最后能跑起来,还算满意,主要是对框架搭建知识太薄弱了,才导致缺包少件的。
最后成功跑起来了,满满的成就感,告别程序员的饭碗却一直忘不了程序员的快感,放不下呐。。。。
这次折腾才发现,我的框架都落后了几代了,我们之前是ssh,现在都更新换代了。光是java就隔了好几代。